From 96b870caca24c2da97a0e9dcce049837c82cdc2a Mon Sep 17 00:00:00 2001 From: augushong Date: Mon, 28 Mar 2022 10:36:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=BC=93=E5=AD=98=E8=AF=BB?= =?UTF-8?q?=E5=8F=96;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/System.php | 2 +- app/model/Post.php | 5 ++--- config/cache.php | 38 ++++++++++++++++----------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/admin/controller/System.php b/app/admin/controller/System.php index ea9d9e5..0606687 100644 --- a/app/admin/controller/System.php +++ b/app/admin/controller/System.php @@ -80,6 +80,6 @@ class System extends Common { Cache::clear(); - return $this->success('清楚成功'); + return $this->success('清除成功'); } } diff --git a/app/model/Post.php b/app/model/Post.php index 8ac2a43..070bc75 100644 --- a/app/model/Post.php +++ b/app/model/Post.php @@ -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')); } diff --git a/config/cache.php b/config/cache.php index 4467583..d8467c8 100644 --- a/config/cache.php +++ b/config/cache.php @@ -9,25 +9,25 @@ use think\facade\Env; return [ - // 默认缓存驱动 - 'default' => Env::get('cache.driver', 'file'), + // 默认缓存驱动 + 'default' => Env::get('cache.driver', 'file'), - // 缓存连接方式配置 - 'stores' => [ - 'file' => [ - // 驱动方式 - 'type' => 'File', - // 缓存保存目录 - 'path' => App::getRootPath() . 'runtime/cache', - // 缓存前缀 - 'prefix' => '', - // 缓存有效期 0表示永久缓存 - 'expire' => 0, - // 缓存标签前缀 - 'tag_prefix' => 'tag:', - // 序列化机制 例如 ['serialize', 'unserialize'] - 'serialize' => [], + // 缓存连接方式配置 + 'stores' => [ + 'file' => [ + // 驱动方式 + 'type' => 'File', + // 缓存保存目录 + 'path' => App::getRootPath() . 'runtime/cache', + // 缓存前缀 + 'prefix' => '', + // 缓存有效期 0表示永久缓存 + 'expire' => 0, + // 缓存标签前缀 + 'tag_prefix' => 'tag:', + // 序列化机制 例如 ['serialize', 'unserialize'] + 'serialize' => [], + ], + // 更多的缓存连接 ], - // 更多的缓存连接 - ], ];