mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
Cache类tag方法增加是否覆盖参数
This commit is contained in:
@@ -168,14 +168,15 @@ class Cache
|
|||||||
/**
|
/**
|
||||||
* 缓存标签
|
* 缓存标签
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $name 标签名
|
* @param string $name 标签名
|
||||||
* @param string|array $keys 缓存标识
|
* @param string|array $keys 缓存标识
|
||||||
|
* @param bool $overlay 是否覆盖
|
||||||
* @return \think\cache\Driver
|
* @return \think\cache\Driver
|
||||||
*/
|
*/
|
||||||
public static function tag($name, $keys = null)
|
public static function tag($name, $keys = null, $overlay = false)
|
||||||
{
|
{
|
||||||
self::init();
|
self::init();
|
||||||
return self::$handler->tag($name, $keys);
|
return self::$handler->tag($name, $keys, $overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
15
library/think/cache/Driver.php
vendored
15
library/think/cache/Driver.php
vendored
@@ -94,11 +94,12 @@ abstract class Driver
|
|||||||
/**
|
/**
|
||||||
* 缓存标签
|
* 缓存标签
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $name 标签名
|
* @param string $name 标签名
|
||||||
* @param string|array $keys 缓存标识
|
* @param string|array $keys 缓存标识
|
||||||
|
* @param bool $overlay 是否覆盖
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function tag($name, $keys = null)
|
public function tag($name, $keys = null, $overlay = false)
|
||||||
{
|
{
|
||||||
if (is_null($keys)) {
|
if (is_null($keys)) {
|
||||||
$this->tag = $name;
|
$this->tag = $name;
|
||||||
@@ -107,8 +108,12 @@ abstract class Driver
|
|||||||
if (is_string($keys)) {
|
if (is_string($keys)) {
|
||||||
$keys = explode(',', $keys);
|
$keys = explode(',', $keys);
|
||||||
}
|
}
|
||||||
$keys = array_map([$this, 'getCacheKey'], $keys);
|
$keys = array_map([$this, 'getCacheKey'], $keys);
|
||||||
$value = array_unique(array_merge($this->getTagItem($name), $keys));
|
if ($overlay) {
|
||||||
|
$value = $keys;
|
||||||
|
} else {
|
||||||
|
$value = array_unique(array_merge($this->getTagItem($name), $keys));
|
||||||
|
}
|
||||||
$this->set($key, implode(',', $value));
|
$this->set($key, implode(',', $value));
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
Reference in New Issue
Block a user