perf(cache): update system configuration and version caching logic

- Add cache update logic for system configurations in Config.php
- Modify version retrieval and caching logic in ConfigService.php
This commit is contained in:
wolfcode
2025-04-02 11:18:42 +08:00
parent db0ac015f0
commit f5813dec99
2 changed files with 3 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ use app\admin\service\annotation\ControllerAnnotation;
use app\admin\service\annotation\NodeAnnotation;
use app\Request;
use think\App;
use think\facade\Cache;
use think\response\Json;
#[ControllerAnnotation(title: '系统配置管理')]
@@ -55,6 +56,7 @@ class Config extends AdminController
'group' => $group,
]);
}
if (Cache::has($key)) Cache::set($key, $val);
}
TriggerService::updateMenu();
TriggerService::updateSysConfig();

View File

@@ -9,11 +9,10 @@ class ConfigService
public static function getVersion()
{
$version = cache('version');
$version = cache('site_version');
if (empty($version)) {
$version = sysConfig('site', 'site_version');
cache('site_version', $version);
Cache::set('version', $version, 3600);
}
return $version;
}