改进文件缓存驱动的clear方法

This commit is contained in:
thinkphp
2016-09-29 20:03:59 +08:00
parent 13ed82e5dd
commit 5098d53ea9
2 changed files with 8 additions and 4 deletions

View File

@@ -221,9 +221,13 @@ class File extends Driver
$this->rm('tag_' . md5($tag));
return true;
}
$fileLsit = (array) glob($this->options['path'] . '*');
foreach ($fileLsit as $path) {
is_file($path) && unlink($path);
$files = (array) glob($this->options['path'] . ($this->options['prefix'] ? $this->options['prefix'] . DS : '') . '*');
foreach ($files as $path) {
if (is_dir($path)) {
array_map('unlink', glob($path . '/*.php'));
} else {
unlink($path);
}
}
return true;
}

View File

@@ -180,6 +180,6 @@ class Lite extends Driver
$this->rm('tag_' . md5($tag));
return true;
}
array_map("unlink", glob($this->options['path'] . $this->options['prefix'] . '*.php'));
array_map("unlink", glob($this->options['path'] . ($this->options['prefix'] ? $this->options['prefix'] . DS : '') . '*.php'));
}
}