Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 837dee4 commit 84f1f28Copy full SHA for 84f1f28
7 files changed
common.h
@@ -782,6 +782,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_key_offset_value, 0, 0, 3)
782
ZEND_ARG_INFO(0, value)
783
ZEND_END_ARG_INFO()
784
785
+ZEND_BEGIN_ARG_INFO_EX(arginfo_swapdb, 0, 0, 2)
786
+ ZEND_ARG_INFO(0, srcdb)
787
+ ZEND_ARG_INFO(0, dstdb)
788
+ZEND_END_ARG_INFO()
789
+
790
ZEND_BEGIN_ARG_INFO_EX(arginfo_key_start_end, 0, 0, 3)
791
ZEND_ARG_INFO(0, key)
792
ZEND_ARG_INFO(0, start)
php_redis.h
@@ -108,6 +108,7 @@ PHP_METHOD(Redis, pttl);
108
PHP_METHOD(Redis, persist);
109
PHP_METHOD(Redis, info);
110
PHP_METHOD(Redis, select);
111
+PHP_METHOD(Redis, swapdb);
112
PHP_METHOD(Redis, move);
113
PHP_METHOD(Redis, zAdd);
114
PHP_METHOD(Redis, zDelete);
redis.c
@@ -387,6 +387,7 @@ static zend_function_entry redis_functions[] = {
387
PHP_ME(Redis, sscan, arginfo_kscan, ZEND_ACC_PUBLIC)
388
PHP_ME(Redis, strlen, arginfo_key, ZEND_ACC_PUBLIC)
389
PHP_ME(Redis, subscribe, arginfo_subscribe, ZEND_ACC_PUBLIC)
390
+ PHP_ME(Redis, swapdb, arginfo_swapdb, ZEND_ACC_PUBLIC)
391
PHP_ME(Redis, time, arginfo_void, ZEND_ACC_PUBLIC)
392
PHP_ME(Redis, ttl, arginfo_key, ZEND_ACC_PUBLIC)
393
PHP_ME(Redis, type, arginfo_key, ZEND_ACC_PUBLIC)
@@ -1832,6 +1833,11 @@ PHP_METHOD(Redis, select) {
1832
1833
}
1834
/* }}} */
1835
1836
+/* {{{ proto bool Redis::swapdb(long srcdb, long dstdb) */
1837
+PHP_METHOD(Redis, swapdb) {
1838
+ REDIS_PROCESS_KW_CMD("SWAPDB", redis_long_long_cmd, redis_boolean_response);
1839
+}
1840
1841
/* {{{ proto bool Redis::move(string key, long dbindex) */
1842
PHP_METHOD(Redis, move) {
1843
REDIS_PROCESS_KW_CMD("MOVE", redis_key_long_cmd, redis_1_response);
redis_commands.c
@@ -333,6 +333,24 @@ int redis_key_long_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
333
return SUCCESS;
334
335
336
+/* long, long */
337
+int redis_long_long_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
338
+ char *kw, char **cmd, int *cmd_len, short *slot,
339
+ void **ctx)
340
+{
341
+ zend_long v1, v2;
342
343
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &v1, &v2)
344
+ == FAILURE)
345
+ {
346
+ return FAILURE;
347
+ }
348
349
+ *cmd_len = REDIS_CMD_SPPRINTF(cmd, kw, "ll", v1, v2);
350
351
+ return SUCCESS;
352
353
354
/* key, long, long */
355
int redis_key_long_long_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
356
char *kw, char **cmd, int *cmd_len, short *slot,
redis_commands.h
@@ -64,6 +64,9 @@ int redis_key_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
64
int redis_key_long_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
65
char *kw, char **cmd, int *cmd_len, short *slot, void **ctx);
66
67
68
+ char *kw, char **cmd, int *cmd_len, short *slot, void **ctx);
69
70
71
72
tests/RedisClusterTest.php
@@ -34,6 +34,7 @@ public function testSelect() { return $this->markTestSkipped(); }
34
public function testReconnectSelect() { return $this->markTestSkipped(); }
35
public function testMultipleConnect() { return $this->markTestSkipped(); }
36
public function testDoublePipeNoOp() { return $this->markTestSkipped(); }
37
+ public function testSwapDB() { return $this->markTestSkipped(); }
38
39
/* Load our seeds on construction */
40
public function __construct() {
tests/RedisTest.php
@@ -1903,6 +1903,11 @@ public function testSelect() {
1903
$this->assertTrue($this->redis->select(0));
1904
1905
1906
+ public function testSwapDB() {
1907
+ $this->assertTrue($this->redis->swapdb(0, 1));
1908
1909
1910
1911
public function testMset() {
1912
$this->redis->del('x', 'y', 'z'); // remove x y z
1913
$this->assertTrue($this->redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'))); // set x y z
0 commit comments