From f6adcfa4bf72ff30f402bfb1dd52131bce493eb3 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 3 Sep 2016 22:12:42 +0800 Subject: [PATCH] =?UTF-8?q?cache=E5=8A=A9=E6=89=8B=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0tag=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/helper.php b/helper.php index 44c469f8..720d93f0 100644 --- a/helper.php +++ b/helper.php @@ -345,9 +345,10 @@ if (!function_exists('cache')) { * @param mixed $name 缓存名称,如果为数组表示进行缓存设置 * @param mixed $value 缓存值 * @param mixed $options 缓存参数 + * @param string $tag 缓存标签 * @return mixed */ - function cache($name, $value = '', $options = null) + function cache($name, $value = '', $options = null, $tag = null) { if (is_array($options)) { // 缓存操作的同时初始化 @@ -369,7 +370,11 @@ if (!function_exists('cache')) { } else { $expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间 } - return Cache::set($name, $value, $expire); + if (is_null($tag)) { + return Cache::set($name, $value, $expire); + } else { + return Cache::tag($tag)->set($name, $value, $expire); + } } } }