diff options
author | michael-grunder <michael.grunder@gmail.com> | 2022-10-10 01:44:29 +0300 |
---|---|---|
committer | Michael Grunder <michael.grunder@gmail.com> | 2022-10-10 18:30:37 +0300 |
commit | 525958ea9fd2f49b3f6683846f0641128d94a00e (patch) | |
tree | 869cd4ee2d0b10b589168718d3bf13138ccf60da | |
parent | 46e64277afccff11b7c616eb86170eaa02d8cb14 (diff) |
Implement CONFIG REWRITE
Closes #847
-rw-r--r-- | redis.c | 8 | ||||
-rw-r--r-- | tests/RedisTest.php | 9 |
2 files changed, 13 insertions, 4 deletions
@@ -2729,8 +2729,10 @@ PHP_METHOD(Redis, config) if (zend_string_equals_literal_ci(op, "GET") && key != NULL) { cmd_len = REDIS_SPPRINTF(&cmd, "CONFIG", "SS", op, key); cb = redis_mbulk_reply_zipped_raw; - } else if (zend_string_equals_literal_ci(op, "RESETSTAT")) { - cmd_len = REDIS_SPPRINTF(&cmd, "CONFIG", "s", ZEND_STRL("RESETSTAT")); + } else if (zend_string_equals_literal_ci(op, "RESETSTAT") || + zend_string_equals_literal_ci(op, "REWRITE")) + { + cmd_len = REDIS_SPPRINTF(&cmd, "CONFIG", "s", ZSTR_VAL(op), ZSTR_LEN(op)); cb = redis_boolean_response; } else if (zend_string_equals_literal_ci(op, "SET") && key != NULL && val != NULL) { cmd_len = REDIS_SPPRINTF(&cmd, "CONFIG", "SSS", op, key, val); @@ -2744,8 +2746,6 @@ PHP_METHOD(Redis, config) cb(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL); } REDIS_PROCESS_RESPONSE(redis_boolean_response); - - return; } /* }}} */ diff --git a/tests/RedisTest.php b/tests/RedisTest.php index d44b0364..4023c37b 100644 --- a/tests/RedisTest.php +++ b/tests/RedisTest.php @@ -5561,6 +5561,15 @@ class Redis_Test extends TestSuite $this->assertFalse($this->redis->config($cmd)); } $this->assertFalse($this->redis->config('set', 'foo')); + + /* REWRITE. We don't care if it actually works, just that the + command be attempted */ + $res = $this->redis->config('rewrite'); + $this->assertTrue(is_bool($res)); + if ($res == false) { + $this->assertPatternMatch($this->redis->getLastError(), '/.*config.*/'); + $this->redis->clearLastError(); + } } public function testReconnectSelect() { |