From 23a0f50a7eb2ba4e08f147d4965cdf5241e1a6f2 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 26 Jul 2016 16:14:54 +0800 Subject: [PATCH] =?UTF-8?q?redis=E7=BC=93=E5=AD=98=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/cache/driver/Redis.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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