diff options
author | michael-grunder <michael.grunder@gmail.com> | 2022-10-14 18:43:00 +0300 |
---|---|---|
committer | Michael Grunder <michael.grunder@gmail.com> | 2022-10-19 19:15:16 +0300 |
commit | 36ef4bd8d16e9f19e194745ba61239bdf19d3851 (patch) | |
tree | 2d65f47fd8c415c068bfe07a2c4a249a00c6c4bb /redis.c | |
parent | b5ea5fd77fe9034ed003db901bbf1f89e15c8ed4 (diff) |
Variadic CONFIG GET/SET
Redis 7.0.0 allows for getting and setting multiple config values as an
atomic operation. In order to support this while maintaining backward
compatibility, the CONFIG command is reworked to also accept an array of
values or keys and values.
See: #2068
Diffstat (limited to 'redis.c')
-rw-r--r-- | redis.c | 43 |
1 files changed, 4 insertions, 39 deletions
@@ -2707,45 +2707,10 @@ PHP_METHOD(Redis, setOption) /* }}} */ /* {{{ proto boolean Redis::config(string op, string key [, mixed value]) */ -PHP_METHOD(Redis, config) -{ - zend_string *op, *key = NULL, *val = NULL; - FailableResultCallback cb; - RedisSock *redis_sock; - zval *object; - int cmd_len; - char *cmd; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OS|SS", &object, - redis_ce, &op, &key, &val) == FAILURE) - { - RETURN_FALSE; - } - - if ((redis_sock = redis_sock_get(object, 0)) == NULL) { - RETURN_FALSE; - } - - 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") || - 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); - cb = redis_boolean_response; - } else { - RETURN_FALSE; - } - - REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len) - if (IS_ATOMIC(redis_sock)) { - cb(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL); - } - REDIS_PROCESS_RESPONSE(redis_boolean_response); +/* {{{ proto public function config(string $op, string ...$args) }}} */ +// CONFIG SET/GET +PHP_METHOD(Redis, config) { + REDIS_PROCESS_CMD(config, redis_config_response); } /* }}} */ |