该行数用来处理缓存,默认下通过 redis 来处理缓存,在 readis 未启动情况下则通过 file 方式来处理缓存。file 所在位置是 \data\cache
。
/**
* KV缓存 写
*
* @param string $key 缓存名称
* @param mixed $value 缓存数据 若设为否 则下次读取该缓存时会触发回调(如果有)
* @param int $expire 缓存时间 单位秒 null代表不过期
* @return boolean
*/
function wkcache($key, $value, $expire = null)
{
if (C('cache_open')) {
$cacher = Cache::getInstance('cacheredis');
} else {
$cacher = Cache::getInstance('file', null);
}
if (!$cacher) {
throw new Exception('Cannot fetch cache object!');
}
return $cacher->set($key, $value, null, $expire);
}