private function checkCache($cacheFile)
{
// 未开启缓存功能
if (!$this->config['tpl_cache']) {
return false;
}
// 缓存文件不存在
if (!is_file($cacheFile)) {
return false;
}
// 读取缓存文件失败
if (!($handle = @fopen($cacheFile, "r"))) {
return false;
}
// 读取第一行
preg_match('/\\/\\*(.+?)\\*\\//', fgets($handle), $matches);
if (!isset($matches[1])) {
return false;
}
$includeFile = unserialize($matches[1]);
if (!is_array($includeFile)) {
return false;
}
// 检查模板文件是否有更新
foreach ($includeFile as $path => $time) {
if (is_file($path) && filemtime($path) > $time) {
// 模板文件如果有更新则缓存需要更新
return false;
}
}
// 检查编译存储是否有效
return $this->storage->check($cacheFile, $this->config['cache_time']);
}