mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
缓存类增加tag方法 用于缓存标签设置 clear方法支持清除某个缓存标签的数据
This commit is contained in:
23
library/think/cache/driver/Wincache.php
vendored
23
library/think/cache/driver/Wincache.php
vendored
@@ -11,19 +11,22 @@
|
||||
|
||||
namespace think\cache\driver;
|
||||
|
||||
use think\cache\Driver;
|
||||
use think\Exception;
|
||||
|
||||
/**
|
||||
* Wincache缓存驱动
|
||||
* @author liu21st <liu21st@gmail.com>
|
||||
*/
|
||||
class Wincache
|
||||
class Wincache extends Driver
|
||||
{
|
||||
protected $options = [
|
||||
'prefix' => '',
|
||||
'expire' => 0,
|
||||
];
|
||||
|
||||
protected $tag;
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
* @param array $options 缓存参数
|
||||
@@ -79,7 +82,11 @@ class Wincache
|
||||
$expire = $this->options['expire'];
|
||||
}
|
||||
$name = $this->options['prefix'] . $name;
|
||||
if ($this->tag && !$this->has($name)) {
|
||||
$first = true;
|
||||
}
|
||||
if (wincache_ucache_set($name, $value, $expire)) {
|
||||
isset($first) && $this->setTagItem($name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -125,10 +132,20 @@ class Wincache
|
||||
/**
|
||||
* 清除缓存
|
||||
* @access public
|
||||
* @param string $tag 标签名
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear()
|
||||
public function clear($tag = null)
|
||||
{
|
||||
return;
|
||||
if ($tag) {
|
||||
$keys = $this->getTagItem($tag);
|
||||
foreach ($keys as $key) {
|
||||
wincache_ucache_delete($key);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return wincache_ucache_clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user