From 3370da9a034c8e58b36990eb040d6c70c57f6762 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 6 Apr 2017 15:01:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3cache=E5=8A=A9=E6=89=8B?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=AF=B9option=E4=BC=A0=E5=8F=82=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/helper.php b/helper.php index da0dc9c5..677b47f5 100644 --- a/helper.php +++ b/helper.php @@ -354,22 +354,25 @@ if (!function_exists('cache')) { { if (is_array($options)) { // 缓存操作的同时初始化 - Cache::connect($options); + $cache = Cache::connect($options); } elseif (is_array($name)) { // 缓存初始化 return Cache::connect($name); + } else { + $cache = Cache::init(); } + if (is_null($name)) { - return Cache::clear($value); + return $cache->clear($value); } elseif ('' === $value) { // 获取缓存 - return 0 === strpos($name, '?') ? Cache::has(substr($name, 1)) : Cache::get($name); + return 0 === strpos($name, '?') ? $cache->has(substr($name, 1)) : $cache->get($name); } elseif (is_null($value)) { // 删除缓存 - return Cache::rm($name); + return $cache->rm($name); } elseif (0 === strpos($name, '?') && '' !== $value) { $expire = is_numeric($options) ? $options : null; - return Cache::remember(substr($name, 1), $value, $expire); + return $cache->remember(substr($name, 1), $value, $expire); } else { // 缓存数据 if (is_array($options)) { @@ -378,9 +381,9 @@ if (!function_exists('cache')) { $expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间 } if (is_null($tag)) { - return Cache::set($name, $value, $expire); + return $cache->set($name, $value, $expire); } else { - return Cache::tag($tag)->set($name, $value, $expire); + return $cache->tag($tag)->set($name, $value, $expire); } } }