完善缓存读取;

This commit is contained in:
2022-03-28 10:36:14 +08:00
parent 807ea5f4f9
commit 96b870caca
3 changed files with 22 additions and 23 deletions

View File

@@ -80,6 +80,6 @@ class System extends Common
{
Cache::clear();
return $this->success('清成功');
return $this->success('清成功');
}
}

View File

@@ -155,7 +155,6 @@ class Post extends Model
$base_dir = App::getRootPath() . '/demo/' . $this->getAttr('category')->getData('tpl_name') . '/';
$file_path = $base_dir . $this->getData('tpl_name') . '.html';
if (!file_exists($file_path)) {
return '';
}
@@ -191,7 +190,7 @@ class Post extends Model
$model_post = Cache::get($cache_key);
if (empty($model_post) || $clear) {
$model_post = Post::find($id);
$model_post = Post::with(['category'], 'left')->find($id);
Cache::set($cache_key, $model_post, get_system_config('cache_expire_time'));
}
@@ -204,7 +203,7 @@ class Post extends Model
$model_post = Cache::get($cache_key);
if (empty($model_post) || $clear) {
$model_post = Post::where('tpl_name', $tpl_name)->find();
$model_post = Post::with(['category'], 'left')->where('tpl_name', $tpl_name)->find();
Cache::set($cache_key, $model_post, get_system_config('cache_expire_time'));
}