From 5098d53ea97cf4935827c0b16cb0ab858257afda Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 29 Sep 2016 20:03:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=96=87=E4=BB=B6=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E9=A9=B1=E5=8A=A8=E7=9A=84clear=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/cache/driver/File.php | 10 +++++++--- library/think/cache/driver/Lite.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/library/think/cache/driver/File.php b/library/think/cache/driver/File.php index ea5688e5..5c98d799 100644 --- a/library/think/cache/driver/File.php +++ b/library/think/cache/driver/File.php @@ -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; } diff --git a/library/think/cache/driver/Lite.php b/library/think/cache/driver/Lite.php index 9e702eed..b9d10097 100644 --- a/library/think/cache/driver/Lite.php +++ b/library/think/cache/driver/Lite.php @@ -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')); } }