From 7ffc6fd7ba25bb0f6fef4d5ad49fc864a86135ae Mon Sep 17 00:00:00 2001 From: EagleWu Date: Wed, 13 Mar 2013 15:42:23 +0800 Subject: [PATCH] Update functions.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复“查询缓存”无法设置过期时间问题 --- ThinkPHP/Common/functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php index 3cefe66d7..9bc95abf1 100644 --- a/ThinkPHP/Common/functions.php +++ b/ThinkPHP/Common/functions.php @@ -380,19 +380,21 @@ function S($name,$value='',$options=null) { // 缓存操作的同时初始化 $type = isset($options['type'])?$options['type']:''; $cache = Cache::getInstance($type,$options); + $expire = is_numeric($options['expire'])?$options['expire']:NULL; //修复查询缓存无法设置过期时间 }elseif(is_array($name)) { // 缓存初始化 $type = isset($name['type'])?$name['type']:''; $cache = Cache::getInstance($type,$name); return $cache; }elseif(empty($cache)) { // 自动初始化 $cache = Cache::getInstance(); + $expire = is_numeric($options)?$options:NULL; //默认快捷缓存设置过期时间 } if(''=== $value){ // 获取缓存 return $cache->get($name); }elseif(is_null($value)) { // 删除缓存 return $cache->rm($name); }else { // 缓存数据 - $expire = is_numeric($options)?$options:NULL; + //$expire = is_numeric($options)?$options:NULL; //原始语句 return $cache->set($name, $value, $expire); } } @@ -768,4 +770,4 @@ function filter_exp(&$value){ if (in_array(strtolower($value),array('exp','or'))){ $value .= ' '; } -} \ No newline at end of file +}