diff --git a/application/common.php b/application/common.php index 9ee2fc97b..585e0990d 100755 --- a/application/common.php +++ b/application/common.php @@ -1293,6 +1293,74 @@ function Authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { } } +/** + * [SS 设置缓存] + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2017-09-24T19:01:00+0800 + * @param [string] $key [缓存key] + * @param [mixed] $data [需要存储的数据] + * @return [boolean] [成功true, 失败false] + */ +function SS($key, $data) +{ + if(empty($key) || empty($data)) + { + return false; + } + + $data['cache_time'] = time(); + return cache($key, $data); +} + +/** + * [GS 获取缓存] + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2017-09-24T18:54:54+0800 + * @param [string] $key [缓存key] + * @param [integer] $expires_time [默认过期时间0长期有效(单位秒)] + * @param [boolean] $is_filem_time [是否返回文件上一次更新时间] + * @return [boolean|mixed] [没数据false, 则数据] + */ +function GS($key, $expires_time = 0, $is_filem_time = false) +{ + if(empty($key)) + { + return false; + } + $data = cache($key); + if($data !== null) + { + $expires_time = intval($expires_time); + if($expires_time > 0) + { + if($data['cache_time']+$expires_time < time()) + { + return false; + } + } + return $data; + } + return false; +} + +/** + * [DS 删除缓存] + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2017-09-24T19:01:00+0800 + * @param [string] $key [缓存key] + * @return [boolean] [成功true, 失败false] + */ +function DS($key) +{ + return cache($key, null); +} + /** * [ParamsChecked 参数校验方法] * @author Devil