首页存储Cache 文件缓存
Cache 文件缓存
Kuoqi\Cache(137 行):文件键值缓存
本页内容
  1. 存储格式
  2. 方法清单

存储格式

说明
文件路径{@ROOT}/Public/Runtime/Cache/{子路径}/{md5名}.cache
文件内容serialize(值) + chr(31) + 过期时间戳
根目录PATH_SYS_CACHE

方法清单

方法签名说明
__construct($name)指定缓存名(文件名 = md5(名称))
readread()读并校验过期(过期自动 remove)
getValuegetValue()惰性读取(内部 read)
removeremove()删除缓存文件
setTimelensetTimelen($time)设置相对当前时间的过期时长
setValuesetValue($value)写入值
setPathsetPath($path)设置子目录
savesave()写入文件
典型用法
// Helper 封装(推荐)
\Kuoqi\Helper::setCache("goods_top", $rows, 300);
$rows = \Kuoqi\Helper::getCache("goods_top");

// 直接使用
$cache = new \Kuoqi\Cache("goods_top");
$cache->setValue($rows);
$cache->setTimelen(300);
$cache->save();
$data = $cache->getValue();
KuoqiPHP v1.05 · 离线静态文档 · 界面基于 KuoqiUI · 返回首页