fix(app): optimize system config caching logic
- Add condition to check if value is not empty or zero before caching-Improve cache efficiency by avoiding unnecessary cache writes
This commit is contained in:
@@ -58,10 +58,10 @@ if (!function_exists('sysConfig')) {
|
||||
if (!empty($name)) {
|
||||
$where['name'] = $name;
|
||||
$value = \app\admin\model\SystemConfig::where($where)->value('value');
|
||||
Cache::tag('sysConfig')->set("sysConfig_{$group}_{$name}", $value, 3600);
|
||||
}else {
|
||||
if (!empty($value) || $value >= 0) Cache::tag('sysConfig')->set("sysConfig_{$group}_{$name}", $value, 3600);
|
||||
} else {
|
||||
$value = \app\admin\model\SystemConfig::where($where)->column('value', 'name');
|
||||
Cache::tag('sysConfig')->set("sysConfig_{$group}", $value, 3600);
|
||||
if (!empty($value) || $value >= 0) Cache::tag('sysConfig')->set("sysConfig_{$group}", $value, 3600);
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
|
||||
Reference in New Issue
Block a user