mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-03 05:52:48 +08:00
Merge pull request #238 from zzpuser/patch-8
修正了延迟递增减后不能清空的计数的问题、修正了延迟递减,数值小于零时不能递减的问题
This commit is contained in:
18
library/think/cache/driver/Memcached.php
vendored
18
library/think/cache/driver/Memcached.php
vendored
@@ -115,7 +115,14 @@ class Memcached
|
||||
*/
|
||||
public function inc($name, $step = 1)
|
||||
{
|
||||
return $this->handler->increment($name, $step);
|
||||
$oldValue = $this->handler->get($this->options['prefix'] . $name);
|
||||
$value = $oldValue + $step;
|
||||
$res = $this->handler->set($this->options['prefix'] . $name, $value);
|
||||
if (!$res) {
|
||||
return false;
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +134,14 @@ class Memcached
|
||||
*/
|
||||
public function dec($name, $step = 1)
|
||||
{
|
||||
return $this->handler->decrement($name, $step);
|
||||
$oldValue = $this->handler->get($this->options['prefix'] . $name);
|
||||
$value = $oldValue - $step;
|
||||
$res = $this->handler->set($this->options['prefix'] . $name, $value);
|
||||
if (!$res) {
|
||||
return false;
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user