mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
缓存类增加tag方法 用于缓存标签设置 clear方法支持清除某个缓存标签的数据
This commit is contained in:
15
library/think/cache/driver/Redis.php
vendored
15
library/think/cache/driver/Redis.php
vendored
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace think\cache\driver;
|
||||
|
||||
use think\cache\Driver;
|
||||
|
||||
/**
|
||||
* Redis缓存驱动,适合单机部署、有前端代理实现高可用的场景,性能最好
|
||||
* 有需要在业务层实现读写分离、或者使用RedisCluster的需求,请使用Redisd驱动
|
||||
@@ -18,7 +20,7 @@ namespace think\cache\driver;
|
||||
* 要求安装phpredis扩展:https://github.com/nicolasff/phpredis
|
||||
* @author 尘缘 <130775@qq.com>
|
||||
*/
|
||||
class Redis
|
||||
class Redis extends Driver
|
||||
{
|
||||
protected $handler = null;
|
||||
protected $options = [
|
||||
@@ -146,10 +148,19 @@ class Redis
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @param string $tag 标签名
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
public function clear($tag = null)
|
||||
{
|
||||
if ($tag) {
|
||||
// 指定标签清除
|
||||
$keys = $this->getTagItem($tag);
|
||||
foreach ($keys as $key) {
|
||||
$this->handler->delete($key);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return $this->handler->flushDB();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user