修正cache助手函数对option传参的支持

This commit is contained in:
thinkphp
2017-04-06 15:01:34 +08:00
parent 4dd5582cdd
commit 3370da9a03

View File

@@ -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);
}
}
}