/** * 缓存管理 * @param mixed $name 缓存名称,如果为数组表示进行缓存设置 * @param mixed $value 缓存值 * @param mixed $options 缓存参数 * @return mixed */ function S($name, $value = '', $options = null) { if (is_array($options)) { // 缓存操作的同时初始化 think\Cache::connect($options); } elseif (is_array($name)) { // 缓存初始化 return think\Cache::connect($name); } if ('' === $value) { // 获取缓存 return think\Cache::get($name); } elseif (is_null($value)) { // 删除缓存 return think\Cache::rm($name); } else { // 缓存数据 if (is_array($options)) { $expire = isset($options['expire']) ? $options['expire'] : null; //修复查询缓存无法设置过期时间 } else { $expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间 } return think\Cache::set($name, $value, $expire); } }