From ba21d222132e8ef2c09c609b2fca42d6b1e6ea2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B4=E5=B9=B3=E5=87=A1?= Date: Tue, 21 Mar 2017 14:05:02 +0800 Subject: [PATCH 1/3] =?UTF-8?q?lazyWrite=E6=96=B9=E6=B3=95=E8=B0=83?= =?UTF-8?q?=E7=94=A8Cache=E7=9A=84inc=E6=96=B9=E6=B3=95=E6=97=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=A4=9A=E4=BD=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index f0f0ec39..66e7c262 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -651,16 +651,16 @@ class Query if (!Cache::has($guid . '_time')) { // 计时开始 Cache::set($guid . '_time', $_SERVER['REQUEST_TIME'], 0); - Cache::$type($guid, $step, 0); + Cache::$type($guid, $step); } elseif ($_SERVER['REQUEST_TIME'] > Cache::get($guid . '_time') + $lazyTime) { // 删除缓存 - $value = Cache::$type($guid, $step, 0); + $value = Cache::$type($guid, $step); Cache::rm($guid); Cache::rm($guid . '_time'); return 0 === $value ? false : $value; } else { // 更新缓存 - Cache::$type($guid, $step, 0); + Cache::$type($guid, $step); } return false; } From b9c47a133271f1af4bd3542317c302904d124ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B4=E5=B9=B3=E5=87=A1?= Date: Tue, 21 Mar 2017 14:06:59 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dinc=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/cache/driver/Memcache.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/think/cache/driver/Memcache.php b/library/think/cache/driver/Memcache.php index 1fbd3b08..b4295e56 100644 --- a/library/think/cache/driver/Memcache.php +++ b/library/think/cache/driver/Memcache.php @@ -113,7 +113,10 @@ class Memcache extends Driver public function inc($name, $step = 1) { $key = $this->getCacheKey($name); - return $this->handler->increment($key, $step); + if( $this->has($name) ){ + return $this->handler->increment($key, $step); + } + return $this->handler->set($key, $step); } /** From 2971e93fd5d91fef8c97873787466d75d0647a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B0=B4=E5=B9=B3=E5=87=A1?= Date: Tue, 21 Mar 2017 14:08:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dinc=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/cache/driver/Memcached.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/think/cache/driver/Memcached.php b/library/think/cache/driver/Memcached.php index fa312e8e..12610646 100644 --- a/library/think/cache/driver/Memcached.php +++ b/library/think/cache/driver/Memcached.php @@ -125,7 +125,10 @@ class Memcached extends Driver public function inc($name, $step = 1) { $key = $this->getCacheKey($name); - return $this->handler->increment($key, $step); + if( $this->has($name) ){ + return $this->handler->increment($key, $step); + } + return $this->handler->set($key, $step); } /**