diff --git a/library/think/cache/driver/Redis.php b/library/think/cache/driver/Redis.php index bfe73206..c1749e27 100644 --- a/library/think/cache/driver/Redis.php +++ b/library/think/cache/driver/Redis.php @@ -106,6 +106,32 @@ class Redis return $result; } + /** + * 自增缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @param int $expire 有效时间 0为永久 + * @return false|int + */ + public function inc($name, $step = 1, $expire = null) + { + return $this->handler->incrby($name, $step); + } + + /** + * 自减缓存(针对数值缓存) + * @access public + * @param string $name 缓存变量名 + * @param int $step 步长 + * @param int $expire 有效时间 0为永久 + * @return false|int + */ + public function dec($name, $step = 1, $expire = null) + { + return $this->handler->decrby($name, $step); + } + /** * 删除缓存 * @access public