mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
修正redis驱动
This commit is contained in:
16
library/think/cache/driver/Redis.php
vendored
16
library/think/cache/driver/Redis.php
vendored
@@ -132,8 +132,12 @@ class Redis extends Driver
|
||||
*/
|
||||
public function inc($name, $step = 1)
|
||||
{
|
||||
$key = $this->getCacheKey($name);
|
||||
return $this->handler->incrby($key, $step);
|
||||
if ($this->has($name)) {
|
||||
$value = $this->get($name) + $step;
|
||||
} else {
|
||||
$value = $step;
|
||||
}
|
||||
return $this->set($name, $value, 0) ? $value : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,8 +149,12 @@ class Redis extends Driver
|
||||
*/
|
||||
public function dec($name, $step = 1)
|
||||
{
|
||||
$key = $this->getCacheKey($name);
|
||||
return $this->handler->decrby($key, $step);
|
||||
if ($this->has($name)) {
|
||||
$value = $this->get($name) - $step;
|
||||
} else {
|
||||
$value = -$step;
|
||||
}
|
||||
return $this->set($name, $value, 0) ? $value : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user