From e0cfaff2a5da6bf149f3487d4044ef7a94fad7c8 Mon Sep 17 00:00:00 2001 From: chenlipeng Date: Wed, 13 Dec 2017 11:17:42 +0800 Subject: [PATCH] fix: lock inttval(N/2)+1 instead fo N/2+1 --- src/RedLock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RedLock.php b/src/RedLock.php index 5f6770a..dc56416 100644 --- a/src/RedLock.php +++ b/src/RedLock.php @@ -18,7 +18,7 @@ function __construct(array $servers, $retryDelay = 200, $retryCount = 3) $this->retryDelay = $retryDelay; $this->retryCount = $retryCount; - $this->quorum = min(count($servers), (count($servers) / 2 + 1)); + $this->quorum = min(count($servers), (intval(count($servers) / 2) + 1)); } public function lock($resource, $ttl)