mirror of
https://gitee.com/ulthon/layui-ul.git
synced 2026-07-01 10:32:49 +08:00
完善缓存读取;
This commit is contained in:
@@ -80,6 +80,6 @@ class System extends Common
|
||||
{
|
||||
Cache::clear();
|
||||
|
||||
return $this->success('清楚成功');
|
||||
return $this->success('清除成功');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
@@ -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' => [],
|
||||
],
|
||||
// 更多的缓存连接
|
||||
],
|
||||
// 更多的缓存连接
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user