修正模板缓存问题

This commit is contained in:
oldrind
2016-03-12 10:08:42 +08:00
parent 71dbdcb874
commit d5483426c2
2 changed files with 11 additions and 11 deletions

View File

@@ -59,16 +59,16 @@ class File
*/ */
public function check($templates, $cacheFile, $cacheTime) public function check($templates, $cacheFile, $cacheTime)
{ {
if (0 != $cacheTime && time() > filemtime($cacheFile) + $cacheTime) {
// 缓存是否在有效期
return false;
}
foreach($templates as $time => $path) { foreach($templates as $time => $path) {
if (is_file($path) && filemtime($path) > $time + $cacheTime) { if (is_file($path) && filemtime($path) > $time) {
// 模板文件如果有更新则缓存需要更新 // 模板文件如果有更新则缓存需要更新
return false; return false;
} }
} }
if (0 != $cacheTime && time() > filemtime($cacheFile) + $cacheTime) {
// 缓存是否在有效期
return false;
}
return true; return true;
} }
} }

View File

@@ -76,17 +76,17 @@ class Sae
*/ */
public function check($templates, $cacheFile, $cacheTime) public function check($templates, $cacheFile, $cacheTime)
{ {
foreach($templates as $time => $path) {
if (is_file($path) && filemtime($path) > $time) {
// 模板文件如果有更新则缓存需要更新
return false;
}
}
$mtime = $this->get($cacheFile, 'mtime'); $mtime = $this->get($cacheFile, 'mtime');
if (0 != $cacheTime && time() > $mtime + $cacheTime) { if (0 != $cacheTime && time() > $mtime + $cacheTime) {
// 缓存是否在有效期 // 缓存是否在有效期
return false; return false;
} }
foreach($templates as $time => $path) {
if (is_file($path) && filemtime($path) > $time + $cacheTime) {
// 模板文件如果有更新则缓存需要更新
return false;
}
}
return true; return true;
} }