public function get($name)
{
$filename = $this->filename($name);
if (!is_file($filename)) {
return false;
}
N('cache_read', 1);
$content = file_get_contents($filename);
if (false !== $content) {
$expire = (int) substr($content, 8, 12);
if ($expire != 0 && time() > filemtime($filename) + $expire) {
//缓存过期删除缓存文件
unlink($filename);
return false;
}
if (C('DATA_CACHE_CHECK')) {
//开启数据校验
$check = substr($content, 20, 32);
$content = substr($content, 52, -3);
if ($check != md5($content)) {
//校验错误
return false;
}
} else {
$content = substr($content, 20, -3);
}
if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
//启用数据压缩
$content = gzuncompress($content);
}
$content = unserialize($content);
return $content;
} else {
return false;
}
}