mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进Cache类的tag方法 支持设置标签的缓存标识
This commit is contained in:
@@ -169,12 +169,13 @@ class Cache
|
||||
* 缓存标签
|
||||
* @access public
|
||||
* @param string $name 标签名
|
||||
* @param string|array $keys 缓存标识
|
||||
* @return \think\cache\Driver
|
||||
*/
|
||||
public static function tag($name)
|
||||
public static function tag($name, $keys = null)
|
||||
{
|
||||
self::init();
|
||||
return self::$handler->tag($name);
|
||||
return self::$handler->tag($name, $keys);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
13
library/think/cache/Driver.php
vendored
13
library/think/cache/Driver.php
vendored
@@ -84,12 +84,19 @@ abstract class Driver
|
||||
* 缓存标签
|
||||
* @access public
|
||||
* @param string $name 标签名
|
||||
* @param string|array $keys 缓存标识
|
||||
* @return $this
|
||||
*/
|
||||
public function tag($name)
|
||||
public function tag($name, $keys = null)
|
||||
{
|
||||
$this->tag = $name;
|
||||
return $this;
|
||||
if (is_null($keys)) {
|
||||
$this->tag = $name;
|
||||
return $this;
|
||||
} else {
|
||||
$key = 'tag_' . md5($name);
|
||||
$value = is_array($keys) ? implode(',', $keys) : $keys;
|
||||
$this->set($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user