Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2022-11-01 06:53:21 +0300
committerMichael Grunder <michael.grunder@gmail.com>2022-11-01 08:32:43 +0300
commitf2cef8be06ed8f308c671df35781e91b16ca3f96 (patch)
tree8f6257ca773ae79aae3887f789f4d7f18d5be4c1 /redis.c
parent7d5db510a0dcacac9ecf89618d1ff9f2c4ab0911 (diff)
More docblocks and refactor SLAVEOF command.
Add additional complete docblocks for a few more commands. Refactor SLAVEOF handler to conform with more modern PhpRedis command handlers. Create REPLICAOF and deprecate SLAVEOF as Redis has done since 5.0.0.
Diffstat (limited to 'redis.c')
-rw-r--r--redis.c41
1 files changed, 9 insertions, 32 deletions
diff --git a/redis.c b/redis.c
index b305075f..0afb4b48 100644
--- a/redis.c
+++ b/redis.c
@@ -2559,41 +2559,18 @@ PHP_METHOD(Redis, bgrewriteaof)
}
/* }}} */
-/* {{{ proto string Redis::slaveof([host, port]) */
-PHP_METHOD(Redis, slaveof)
-{
- zval *object;
- RedisSock *redis_sock;
- char *cmd = "", *host = NULL;
- size_t host_len;
- zend_long port = 6379;
- int cmd_len;
-
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
- "O|sl", &object, redis_ce, &host,
- &host_len, &port) == FAILURE)
- {
- RETURN_FALSE;
- }
- if (port < 0 || (redis_sock = redis_sock_get(object, 0)) == NULL) {
- RETURN_FALSE;
- }
-
- if (host && host_len) {
- cmd_len = REDIS_SPPRINTF(&cmd, "SLAVEOF", "sd", host, host_len, (int)port);
- } else {
- cmd_len = REDIS_SPPRINTF(&cmd, "SLAVEOF", "ss", "NO", 2, "ONE", 3);
- }
-
- REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
- if (IS_ATOMIC(redis_sock)) {
- redis_boolean_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock,
- NULL, NULL);
- }
- REDIS_PROCESS_RESPONSE(redis_boolean_response);
+/* {{{ public function slaveof(string $host = NULL, int $port = NULL): Redis|bool }}} */
+PHP_METHOD(Redis, slaveof) {
+ REDIS_PROCESS_KW_CMD("SLAVEOF", redis_replicaof_cmd, redis_boolean_response);
}
/* }}} */
+/* {{{ public function replicaof(string $host = NULL, int $port = NULL): Redis|bool }}} */
+PHP_METHOD(Redis, replicaof) {
+ REDIS_PROCESS_KW_CMD("REPLICAOF", redis_replicaof_cmd, redis_boolean_response);
+}
+
+/* }}} */
/* {{{ proto string Redis::object(key) */
PHP_METHOD(Redis, object)
{