改进文件缓存

This commit is contained in:
thinkphp
2017-08-15 14:39:02 +08:00
parent 930de63aba
commit db965e1786

View File

@@ -112,8 +112,6 @@ class File extends Driver
if (0 != $expire && $_SERVER['REQUEST_TIME'] > filemtime($filename) + $expire && !is_file($filename . '.lock')) { if (0 != $expire && $_SERVER['REQUEST_TIME'] > filemtime($filename) + $expire && !is_file($filename . '.lock')) {
// 生成过期锁定文件 // 生成过期锁定文件
touch($filename . '.lock'); touch($filename . '.lock');
// 缓存过期删除缓存文件
$this->unlink($filename);
return $default; return $default;
} }
$content = substr($content, 20, -3); $content = substr($content, 20, -3);
@@ -207,7 +205,12 @@ class File extends Driver
*/ */
public function rm($name) public function rm($name)
{ {
return $this->unlink($this->getCacheKey($name)); $filename = $this->getCacheKey($name);
if (is_file($filename . '.lock')) {
// 解除过期锁定文件
unlink($filename . '.lock');
}
return $this->unlink($filename);
} }
/** /**