mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
修正cache助手函数对option传参的支持
This commit is contained in:
17
helper.php
17
helper.php
@@ -354,22 +354,25 @@ if (!function_exists('cache')) {
|
|||||||
{
|
{
|
||||||
if (is_array($options)) {
|
if (is_array($options)) {
|
||||||
// 缓存操作的同时初始化
|
// 缓存操作的同时初始化
|
||||||
Cache::connect($options);
|
$cache = Cache::connect($options);
|
||||||
} elseif (is_array($name)) {
|
} elseif (is_array($name)) {
|
||||||
// 缓存初始化
|
// 缓存初始化
|
||||||
return Cache::connect($name);
|
return Cache::connect($name);
|
||||||
|
} else {
|
||||||
|
$cache = Cache::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($name)) {
|
if (is_null($name)) {
|
||||||
return Cache::clear($value);
|
return $cache->clear($value);
|
||||||
} elseif ('' === $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)) {
|
} elseif (is_null($value)) {
|
||||||
// 删除缓存
|
// 删除缓存
|
||||||
return Cache::rm($name);
|
return $cache->rm($name);
|
||||||
} elseif (0 === strpos($name, '?') && '' !== $value) {
|
} elseif (0 === strpos($name, '?') && '' !== $value) {
|
||||||
$expire = is_numeric($options) ? $options : null;
|
$expire = is_numeric($options) ? $options : null;
|
||||||
return Cache::remember(substr($name, 1), $value, $expire);
|
return $cache->remember(substr($name, 1), $value, $expire);
|
||||||
} else {
|
} else {
|
||||||
// 缓存数据
|
// 缓存数据
|
||||||
if (is_array($options)) {
|
if (is_array($options)) {
|
||||||
@@ -378,9 +381,9 @@ if (!function_exists('cache')) {
|
|||||||
$expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间
|
$expire = is_numeric($options) ? $options : null; //默认快捷缓存设置过期时间
|
||||||
}
|
}
|
||||||
if (is_null($tag)) {
|
if (is_null($tag)) {
|
||||||
return Cache::set($name, $value, $expire);
|
return $cache->set($name, $value, $expire);
|
||||||
} else {
|
} else {
|
||||||
return Cache::tag($tag)->set($name, $value, $expire);
|
return $cache->tag($tag)->set($name, $value, $expire);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user