mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
修正缓存驱动
This commit is contained in:
10
library/think/cache/driver/Memcache.php
vendored
10
library/think/cache/driver/Memcache.php
vendored
@@ -109,6 +109,7 @@ class Memcache
|
|||||||
*/
|
*/
|
||||||
public function inc($name, $step = 1)
|
public function inc($name, $step = 1)
|
||||||
{
|
{
|
||||||
|
$name = $this->options['prefix'] . $name;
|
||||||
return $this->handler->increment($name, $step);
|
return $this->handler->increment($name, $step);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +122,14 @@ class Memcache
|
|||||||
*/
|
*/
|
||||||
public function dec($name, $step = 1)
|
public function dec($name, $step = 1)
|
||||||
{
|
{
|
||||||
return $this->handler->decrement($name, $step);
|
$name = $this->options['prefix'] . $name;
|
||||||
|
$value = $this->handler->get($name) - $step;
|
||||||
|
$res = $this->handler->set($name, $value);
|
||||||
|
if (!$res) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
16
library/think/cache/driver/Memcached.php
vendored
16
library/think/cache/driver/Memcached.php
vendored
@@ -115,14 +115,8 @@ class Memcached
|
|||||||
*/
|
*/
|
||||||
public function inc($name, $step = 1)
|
public function inc($name, $step = 1)
|
||||||
{
|
{
|
||||||
$oldValue = $this->handler->get($this->options['prefix'] . $name);
|
$name = $this->options['prefix'] . $name;
|
||||||
$value = $oldValue + $step;
|
return $this->handler->increment($name, $step);
|
||||||
$res = $this->handler->set($this->options['prefix'] . $name, $value);
|
|
||||||
if (!$res) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,9 +128,9 @@ class Memcached
|
|||||||
*/
|
*/
|
||||||
public function dec($name, $step = 1)
|
public function dec($name, $step = 1)
|
||||||
{
|
{
|
||||||
$oldValue = $this->handler->get($this->options['prefix'] . $name);
|
$name = $this->options['prefix'] . $name;
|
||||||
$value = $oldValue - $step;
|
$value = $this->handler->get($name) - $step;
|
||||||
$res = $this->handler->set($this->options['prefix'] . $name, $value);
|
$res = $this->handler->set($name, $value);
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
2
library/think/cache/driver/Redis.php
vendored
2
library/think/cache/driver/Redis.php
vendored
@@ -115,6 +115,7 @@ class Redis
|
|||||||
*/
|
*/
|
||||||
public function inc($name, $step = 1)
|
public function inc($name, $step = 1)
|
||||||
{
|
{
|
||||||
|
$name = $this->options['prefix'] . $name;
|
||||||
return $this->handler->incrby($name, $step);
|
return $this->handler->incrby($name, $step);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +128,7 @@ class Redis
|
|||||||
*/
|
*/
|
||||||
public function dec($name, $step = 1)
|
public function dec($name, $step = 1)
|
||||||
{
|
{
|
||||||
|
$name = $this->options['prefix'] . $name;
|
||||||
return $this->handler->decrby($name, $step);
|
return $this->handler->decrby($name, $step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
library/think/cache/driver/Wincache.php
vendored
2
library/think/cache/driver/Wincache.php
vendored
@@ -94,6 +94,7 @@ class Wincache
|
|||||||
*/
|
*/
|
||||||
public function inc($name, $step = 1)
|
public function inc($name, $step = 1)
|
||||||
{
|
{
|
||||||
|
$name = $this->options['prefix'] . $name;
|
||||||
return wincache_ucache_inc($name, $step);
|
return wincache_ucache_inc($name, $step);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +107,7 @@ class Wincache
|
|||||||
*/
|
*/
|
||||||
public function dec($name, $step = 1)
|
public function dec($name, $step = 1)
|
||||||
{
|
{
|
||||||
|
$name = $this->options['prefix'] . $name;
|
||||||
return wincache_ucache_dec($name, $step);
|
return wincache_ucache_dec($name, $step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
library/think/cache/driver/Xcache.php
vendored
2
library/think/cache/driver/Xcache.php
vendored
@@ -94,6 +94,7 @@ class Xcache
|
|||||||
*/
|
*/
|
||||||
public function inc($name, $step = 1)
|
public function inc($name, $step = 1)
|
||||||
{
|
{
|
||||||
|
$name = $this->options['prefix'] . $name;
|
||||||
return xcache_inc($name, $step);
|
return xcache_inc($name, $step);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +107,7 @@ class Xcache
|
|||||||
*/
|
*/
|
||||||
public function dec($name, $step = 1)
|
public function dec($name, $step = 1)
|
||||||
{
|
{
|
||||||
|
$name = $this->options['prefix'] . $name;
|
||||||
return xcache_dec($name, $step);
|
return xcache_dec($name, $step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user