From af2d18f923f7ed9684d05229db4c64f966258d16 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 22 Jan 2018 17:16:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96File=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E7=A9=BA=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= 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, 6 insertions(+), 4 deletions(-) diff --git a/library/think/cache/driver/File.php b/library/think/cache/driver/File.php index a072f41f..6b1abd19 100644 --- a/library/think/cache/driver/File.php +++ b/library/think/cache/driver/File.php @@ -63,10 +63,11 @@ class File extends Driver /** * 取得变量的存储文件名 * @access protected - * @param string $name 缓存变量名 + * @param string $name 缓存变量名 + * @param bool $auto 是否自动创建目录 * @return string */ - protected function getCacheKey($name) + protected function getCacheKey($name, $auto = false) { $name = md5($name); if ($this->options['cache_subdir']) { @@ -78,7 +79,8 @@ class File extends Driver } $filename = $this->options['path'] . $name . '.php'; $dir = dirname($filename); - if (!is_dir($dir)) { + + if ($auto && !is_dir($dir)) { mkdir($dir, 0755, true); } return $filename; @@ -144,7 +146,7 @@ class File extends Driver if ($expire instanceof \DateTime) { $expire = $expire->getTimestamp() - time(); } - $filename = $this->getCacheKey($name); + $filename = $this->getCacheKey($name, true); if ($this->tag && !is_file($filename)) { $first = true; }