mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-04 00:24:29 +08:00
完成自动缓存和缓存清理;
This commit is contained in:
@@ -57,6 +57,7 @@ function get_system_config($name = '', $default = '')
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
$list = SystemConfig::column('value', 'name');
|
$list = SystemConfig::column('value', 'name');
|
||||||
|
Cache::set('system_config',$list);
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace app\common\model;
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use app\common\traits\AutoClearCache;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|
||||||
class Base extends Model
|
class Base extends Model
|
||||||
{
|
{
|
||||||
// use AutoClearCache;
|
use AutoClearCache;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ trait AutoClearCache
|
|||||||
{
|
{
|
||||||
|
|
||||||
foreach (static::$autoClearCache as $cache_item) {
|
foreach (static::$autoClearCache as $cache_item) {
|
||||||
$type = $cache_item['type'] ?: 'key';
|
$type = $cache_item['type'] ?? 'key';
|
||||||
|
|
||||||
$field = $cache_item['field'] ?: '';
|
$field = $cache_item['field'] ?? '';
|
||||||
|
|
||||||
$cache_key = $cache_item['name'] ?: '';
|
$cache_key = $cache_item['name'] ?? '';
|
||||||
|
|
||||||
if (empty($cache_key)) {
|
if (empty($cache_key)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -56,7 +56,7 @@ trait AutoClearCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'key') {
|
if ($type == 'key') {
|
||||||
Cache::delete($type);
|
Cache::delete($cache_key);
|
||||||
} else {
|
} else {
|
||||||
Cache::tag($cache_key)->clear();
|
Cache::tag($cache_key)->clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class Common extends BaseController
|
|||||||
{
|
{
|
||||||
parent::initialize();
|
parent::initialize();
|
||||||
|
|
||||||
|
|
||||||
$list_nav_slide = Nav::where('type', 3)->cache('type_3_list')->order('sort asc')->where('status', 1)->select();
|
$list_nav_slide = Nav::where('type', 3)->cache('type_3_list')->order('sort asc')->where('status', 1)->select();
|
||||||
|
|
||||||
View::assign('list_nav_slide', $list_nav_slide);
|
View::assign('list_nav_slide', $list_nav_slide);
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ return [
|
|||||||
// 页面Trace调试
|
// 页面Trace调试
|
||||||
// \think\middleware\TraceDebug::class,
|
// \think\middleware\TraceDebug::class,
|
||||||
|
|
||||||
// '\app\\middleware\ConfigInit'
|
'\app\\middleware\ConfigInit'
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user