改进缓存标签的设置和删除

This commit is contained in:
thinkphp
2016-08-17 19:07:29 +08:00
parent 684c04849a
commit 90fc917b00
9 changed files with 112 additions and 78 deletions

View File

@@ -51,8 +51,8 @@ class Wincache extends Driver
*/
public function has($name)
{
$name = $this->options['prefix'] . $name;
return wincache_ucache_exists($name);
$key = $this->getCacheKey($name);
return wincache_ucache_exists($key);
}
/**
@@ -64,8 +64,8 @@ class Wincache extends Driver
*/
public function get($name, $default = false)
{
$name = $this->options['prefix'] . $name;
return wincache_ucache_exists($name) ? wincache_ucache_get($name) : $default;
$key = $this->getCacheKey($name);
return wincache_ucache_exists($key) ? wincache_ucache_get($key) : $default;
}
/**
@@ -81,12 +81,12 @@ class Wincache extends Driver
if (is_null($expire)) {
$expire = $this->options['expire'];
}
$name = $this->options['prefix'] . $name;
$key = $this->getCacheKey($name);
if ($this->tag && !$this->has($name)) {
$first = true;
}
if (wincache_ucache_set($name, $value, $expire)) {
isset($first) && $this->setTagItem($name);
if (wincache_ucache_set($key, $value, $expire)) {
isset($first) && $this->setTagItem($key);
return true;
}
return false;
@@ -101,8 +101,8 @@ class Wincache extends Driver
*/
public function inc($name, $step = 1)
{
$name = $this->options['prefix'] . $name;
return wincache_ucache_inc($name, $step);
$key = $this->getCacheKey($name);
return wincache_ucache_inc($key, $step);
}
/**
@@ -114,8 +114,8 @@ class Wincache extends Driver
*/
public function dec($name, $step = 1)
{
$name = $this->options['prefix'] . $name;
return wincache_ucache_dec($name, $step);
$key = $this->getCacheKey($name);
return wincache_ucache_dec($key, $step);
}
/**
@@ -126,7 +126,7 @@ class Wincache extends Driver
*/
public function rm($name)
{
return wincache_ucache_delete($this->options['prefix'] . $name);
return wincache_ucache_delete($this->getCacheKey($name));
}
/**
@@ -142,6 +142,7 @@ class Wincache extends Driver
foreach ($keys as $key) {
wincache_ucache_delete($key);
}
$this->rm('tag_' . md5($tag));
return true;
} else {
return wincache_ucache_clear();