where('key',$key)->find(); $value = serialize($value); if ($edit) { $edit->value = $value; $Setting = $edit->save(); } else { $Setting = $Setting->save(['key' => $key, 'value' => $value]); } # 添加缓存 Cache::store('redis')->set($key,$value); return true; } /** * 获取缓存 * @param $key * @return array|string * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public static function settingLoad($key) { # 获取缓存 $catch = Cache::store('redis')->get($key); if (empty($catch)) { $Setting = new Setting(); $Setting = $Setting->where('key',$key)->find(); if (!$Setting) return ''; $catch = $Setting->value; # 添加缓存 Cache::store('redis')->set($key,$catch); } return unserialize($catch); } }