From b53038f916eb997006484ca5853a3f6672bbd044 Mon Sep 17 00:00:00 2001 From: Xon Date: Thu, 22 Mar 2018 09:58:36 +0800 Subject: [PATCH 1/4] Test against redis v4 --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3fbff2d..b9c13ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,10 @@ allow_failures: install: - yes '' | pecl install -f redis - - wget http://download.redis.io/releases/redis-3.2.11.tar.gz - - tar -xzf redis-3.2.11.tar.gz - - make -s -C redis-3.2.11 -j4 - - export PATH=$PATH:$PWD/redis-3.2.11/src/ + - wget http://download.redis.io/releases/redis-4.0.8.tar.gz + - tar -xzf redis-4.0.8.tar.gz + - make -s -C redis-4.0.8 -j4 + - export PATH=$PATH:$PWD/redis-4.0.8/src/ script: - phpunit From 864191d861ecdee67ed15fce069aca53667cd185 Mon Sep 17 00:00:00 2001 From: Xon Date: Thu, 22 Mar 2018 10:16:06 +0800 Subject: [PATCH 2/4] add exists tests --- tests/CredisTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/CredisTest.php b/tests/CredisTest.php index d6fac5e..968000e 100644 --- a/tests/CredisTest.php +++ b/tests/CredisTest.php @@ -65,6 +65,10 @@ public function testScalars() $this->assertEquals('FOO', $this->credis->get('foo')); $this->assertFalse($this->credis->get('nil')); + // exists support + $this->assertEquals($this->credis->exists('foo'), 1); + $this->assertEquals($this->credis->exists('nil'), 0); + // Empty string $this->credis->set('empty',''); $this->assertEquals('', $this->credis->get('empty')); From d764510d057ee672d363a5032f7df2bc2c0e7985 Mon Sep 17 00:00:00 2001 From: Xon Date: Thu, 22 Mar 2018 10:20:49 +0800 Subject: [PATCH 3/4] Smooth over phpredis exists return results to ensure it is an int value --- Client.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Client.php b/Client.php index 2f32faf..971b8f1 100755 --- a/Client.php +++ b/Client.php @@ -1186,6 +1186,17 @@ public function __call($name, $args) throw new CredisException($error); } break; + case 'exists': + // smooth over phpredis-v4 vs earlier difference to match documented credis return results + if ($response === true) + { + $response = 1; + } + else if ($response === false) + { + $response = 0; + } + break; default: $error = $this->redis->getLastError(); $this->redis->clearLastError(); From 501b633be41afdc8cc01b0e2207fd23d7ccb0836 Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Mon, 7 May 2018 10:34:53 -0400 Subject: [PATCH 4/4] Simplify type casting. --- Client.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Client.php b/Client.php index 971b8f1..f4536b6 100755 --- a/Client.php +++ b/Client.php @@ -1188,14 +1188,7 @@ public function __call($name, $args) break; case 'exists': // smooth over phpredis-v4 vs earlier difference to match documented credis return results - if ($response === true) - { - $response = 1; - } - else if ($response === false) - { - $response = 0; - } + $response = (int) $response; break; default: $error = $this->redis->getLastError();