Permalink
Browse files

Update 'master' to '4.0.2'

  • Loading branch information...
yatsukhnenko committed Apr 25, 2018
2 parents 95aa6de + 61052e1 commit 00d589d888bab11cf23a428766fff1b034d051db
Showing with 54 additions and 19 deletions.
  1. +18 −9 package.xml
  2. +1 −1 php_redis.h
  3. +1 −1 redis.c
  4. +1 −1 redis_cluster.c
  5. +8 −0 redis_commands.c
  6. +3 −0 redis_commands.h
  7. +2 −2 tests/RedisArrayTest.php
  8. +20 −5 tests/RedisTest.php
View
@@ -27,24 +27,21 @@ http://pear.php.net/dtd/package-2.0.xsd">
<email>p.yatsukhnenko@gmail.com</email>
<active>yes</active>
</lead>
- <date>2018-04-18</date>
+ <date>2018-04-25</date>
<version>
- <release>4.0.1</release>
- <api>4.0.1</api>
+ <release>4.0.2</release>
+ <api>4.0.2</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>
- phpredis 4.0.1
+ phpredis 4.0.2
- * Fix arginfo for connect/pconnect issue #1337 [c3b228] (@mathroc)
- * Don't leak a ZVAL [278232] (Michael Grunder)
- * Fix config.m4 for lzf issue #1325 [20e173] (Pavlo Yatsukhnenko)
- * Updates EXISTS documentation and notes change in 4.0.0 [bed186] (Michael Grunder)
- * Fix typo in notes [0bed36] (@szepeviktor)
+ This release contains only fix of exists method to take multiple keys
+ and return integer value (was broken in 4.0.1) Thanks @RanjanRohit!
</notes>
<contents>
<dir name="/">
@@ -109,6 +106,18 @@ http://pear.php.net/dtd/package-2.0.xsd">
<configureoption name="enable-redis-lzf" prompt="enable lzf compression support?" default="no"/>
</extsrcrelease>
<changelog>
+ <release>
+ <stability><release>stable</release><api>stable</api></stability>
+ <version><release>4.0.2</release><api>4.0.2</api></version>
+ <date>2018-04-25</date>
+ <notes>
+ phpredis 4.0.2
+
+ This release contains only fix of exists method to take multiple keys
+ and return integer value (was broken in 4.0.1) Thanks @RanjanRohit!
+ </notes>
+ </release>
+
<release>
<stability><release>stable</release><api>stable</api></stability>
<version><release>4.0.1</release><api>4.0.1</api></version>
View
@@ -25,7 +25,7 @@
#define PHP_REDIS_H
/* phpredis version */
-#define PHP_REDIS_VERSION "4.0.1"
+#define PHP_REDIS_VERSION "4.0.2"
PHP_METHOD(Redis, __construct);
PHP_METHOD(Redis, __destruct);
View
@@ -1169,7 +1169,7 @@ PHP_METHOD(Redis, getMultiple)
*/
PHP_METHOD(Redis, exists)
{
- REDIS_PROCESS_KW_CMD("EXISTS", redis_key_cmd, redis_1_response);
+ REDIS_PROCESS_CMD(exists, redis_long_response);
}
/* }}} */
View
@@ -1063,7 +1063,7 @@ PHP_METHOD(RedisCluster, getset) {
/* {{{ proto int RedisCluster::exists(string key) */
PHP_METHOD(RedisCluster, exists) {
- CLUSTER_PROCESS_KW_CMD("EXISTS", redis_key_cmd, cluster_1_resp, 1);
+ CLUSTER_PROCESS_CMD(exists, cluster_long_resp, 1);
}
/* }}} */
View
@@ -2879,6 +2879,14 @@ int redis_migrate_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
return SUCCESS;
}
+/* EXISTS */
+int redis_exists_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
+ char **cmd, int *cmd_len, short *slot, void **ctx)
+{
+ return gen_varkey_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
+ "EXISTS", sizeof("EXISTS") - 1, 0, 0, cmd, cmd_len, slot);
+}
+
/* DEL */
int redis_del_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
char **cmd, int *cmd_len, short *slot, void **ctx)
View
@@ -206,6 +206,9 @@ int redis_object_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
REDIS_REPLY_TYPE *rtype, char **cmd, int *cmd_len, short *slot,
void **ctx);
+int redis_exists_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
+ char **cmd, int *cmd_len, short *slot, void **ctx);
+
int redis_del_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
char **cmd, int *cmd_len, short *slot, void **ctx);
View
@@ -491,8 +491,8 @@ public function testMultiExecDel() {
->exec();
$this->assertTrue($out[0] === 2);
- $this->assertTrue($this->ra->exists('1_{employee:joe}_group') === FALSE);
- $this->assertTrue($this->ra->exists('1_{employee:joe}_salary') === FALSE);
+ $this->assertEquals(0, $this->ra->exists('1_{employee:joe}_group'));
+ $this->assertEquals(0, $this->ra->exists('1_{employee:joe}_salary'));
}
public function testMutliExecUnlink() {
View
@@ -354,7 +354,7 @@ public function testGetSet() {
public function testRandomKey() {
for($i = 0; $i < 1000; $i++) {
$k = $this->redis->randomKey();
- $this->assertTrue($this->redis->exists($k));
+ $this->assertEquals($this->redis->exists($k), 1);
}
}
@@ -555,7 +555,7 @@ public function testIncrByFloat()
$this->redis->incrbyfloat('key',1.8);
$this->assertEquals(1.8, floatval($this->redis->get('key'))); // convert to float to avoid rounding issue on arm
$this->redis->setOption(Redis::OPT_PREFIX, '');
- $this->assertTrue($this->redis->exists('someprefix:key'));
+ $this->assertEquals(1, $this->redis->exists('someprefix:key'));
$this->redis->del('someprefix:key');
}
@@ -586,10 +586,25 @@ public function testDecr()
public function testExists()
{
+ /* Single key */
$this->redis->del('key');
- $this->assertFalse($this->redis->exists('key'));
+ $this->assertEquals(0, $this->redis->exists('key'));
$this->redis->set('key', 'val');
- $this->assertEquals(True, $this->redis->exists('key'));
+ $this->assertEquals(1, $this->redis->exists('key'));
+
+ /* Add multiple keys */
+ $mkeys = Array();
+ for ($i = 0; $i < 10; $i++) {
+ if (rand(1, 2) == 1) {
+ $mkey = "{exists}key:$i";
+ $this->redis->set($mkey, $i);
+ $mkeys[] = $mkey;
+ }
+ }
+
+ /* Test passing an array as well as the keys variadic */
+ $this->assertEquals(count($mkeys), $this->redis->exists($mkeys));
+ $this->assertEquals(count($mkeys), call_user_func_array(Array($this->redis, 'exists'), $mkeys));
}
public function testGetKeys()
@@ -4129,7 +4144,7 @@ private function checkSerializer($mode) {
$this->redis->sAdd('k', 'a', 'b', 'c', 'd');
$this->assertTrue(2 === $this->redis->sRem('k', 'a', 'd'));
$this->assertTrue(2 === $this->redis->sRem('k', 'b', 'c', 'e'));
- $this->assertTrue(FALSE === $this->redis->exists('k'));
+ $this->assertEquals(0, $this->redis->exists('k'));
// sismember
$this->assertTrue(TRUE === $this->redis->sismember('{set}key', $s[0]));

0 comments on commit 00d589d

Please sign in to comment.