mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
删除不存在的File缓存时异常
增加删除本地文件缓存时优先判断是否存在,如果存在则进行unlink删除操作
This commit is contained in:
20
library/think/cache/driver/File.php
vendored
20
library/think/cache/driver/File.php
vendored
@@ -104,7 +104,7 @@ class File
|
|||||||
$expire = (int) substr($content, 8, 12);
|
$expire = (int) substr($content, 8, 12);
|
||||||
if (0 != $expire && time() > filemtime($filename) + $expire) {
|
if (0 != $expire && time() > filemtime($filename) + $expire) {
|
||||||
//缓存过期删除缓存文件
|
//缓存过期删除缓存文件
|
||||||
unlink($filename);
|
$this->unlink($filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$content = substr($content, 20, -3);
|
$content = substr($content, 20, -3);
|
||||||
@@ -157,7 +157,7 @@ class File
|
|||||||
// 出列
|
// 出列
|
||||||
$key = array_shift($queue);
|
$key = array_shift($queue);
|
||||||
// 删除缓存
|
// 删除缓存
|
||||||
unlink($this->filename($key));
|
$this->unlink($this->filename($key));
|
||||||
}
|
}
|
||||||
file_put_contents($queue_file, serialize($queue));
|
file_put_contents($queue_file, serialize($queue));
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ class File
|
|||||||
*/
|
*/
|
||||||
public function rm($name)
|
public function rm($name)
|
||||||
{
|
{
|
||||||
return unlink($this->filename($name));
|
return $this->unlink($this->filename($name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,7 +191,7 @@ class File
|
|||||||
while ($file = readdir($dir)) {
|
while ($file = readdir($dir)) {
|
||||||
$check = is_dir($file);
|
$check = is_dir($file);
|
||||||
if (!$check) {
|
if (!$check) {
|
||||||
unlink($path . $file);
|
$this->unlink($path . $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -199,4 +199,16 @@ class File
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断文件是否存在后,删除
|
||||||
|
* @param $path
|
||||||
|
* @return bool
|
||||||
|
* @author byron sampson <xiaobo.sun@qq.com>
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private function unlink($path)
|
||||||
|
{
|
||||||
|
return is_file($path) && unlink($path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user