From 930de63aba70c0b921253bd8e72bc632ac64c9b6 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 15 Aug 2017 12:14:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=BC=93=E5=AD=98=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=AB=98=E5=B9=B6=E5=8F=91=E9=94=81=E5=AE=9A=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/cache/driver/File.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/think/cache/driver/File.php b/library/think/cache/driver/File.php index 5aadb2b1..4d975ee0 100644 --- a/library/think/cache/driver/File.php +++ b/library/think/cache/driver/File.php @@ -109,8 +109,10 @@ class File extends Driver $content = file_get_contents($filename); if (false !== $content) { $expire = (int) substr($content, 8, 12); - if (0 != $expire && $_SERVER['REQUEST_TIME'] > filemtime($filename) + $expire) { - //缓存过期删除缓存文件 + if (0 != $expire && $_SERVER['REQUEST_TIME'] > filemtime($filename) + $expire && !is_file($filename . '.lock')) { + // 生成过期锁定文件 + touch($filename . '.lock'); + // 缓存过期删除缓存文件 $this->unlink($filename); return $default; } @@ -152,6 +154,10 @@ class File extends Driver $result = file_put_contents($filename, $data); if ($result) { isset($first) && $this->setTagItem($filename); + if (is_file($filename . '.lock')) { + // 解除过期锁定文件 + unlink($filename . '.lock'); + } clearstatcache(); return true; } else {