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>2019-01-24 19:36:58 +0300
committerGitHub <noreply@github.com>2019-01-24 19:36:58 +0300
commit15995c06e39fee6249a0fc584b50e8893521fe52 (patch)
treecc35728696c9b02f142253ae0cba869066d118b6 /redis_commands.c
parent3aad9e653bf85072602a1f3b8dcf888891a9206e (diff)
Xgroup updates (#1499)
Adds support for XGROUP CREATE ... MKSTREAM, and support at all for XGROUP DESTROY.
Diffstat (limited to 'redis_commands.c')
-rw-r--r--redis_commands.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/redis_commands.c b/redis_commands.c
index 7548d742..9dbb40f7 100644
--- a/redis_commands.c
+++ b/redis_commands.c
@@ -3722,20 +3722,21 @@ int redis_xclaim_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
}
/* XGROUP HELP
+ * XGROUP CREATE key groupname id [MKSTREAM]
* XGROUP SETID key group id
- * XGROUP DELGROUP key groupname
- * XGROUP CREATE key groupname id
+ * XGROUP DESTROY key groupname
* XGROUP DELCONSUMER key groupname consumername */
int redis_xgroup_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
char **cmd, int *cmd_len, short *slot, void **ctx)
{
char *op, *key = NULL, *arg1 = NULL, *arg2 = NULL;
strlen_t oplen, keylen, arg1len, arg2len;
+ zend_bool mkstream = 0;
int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ssss", &op, &oplen,
- &key, &keylen, &arg1, &arg1len, &arg2, &arg2len)
- == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sssb", &op, &oplen,
+ &key, &keylen, &arg1, &arg1len, &arg2, &arg2len,
+ &mkstream) == FAILURE)
{
return FAILURE;
}
@@ -3743,14 +3744,23 @@ int redis_xgroup_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
if (argc == 1 && oplen == 4 && !strncasecmp(op, "HELP", 4)) {
*cmd_len = REDIS_CMD_SPPRINTF(cmd, "XGROUP", "s", "HELP", 4);
return SUCCESS;
+ } else if (argc >= 4 && (oplen == 6 && !strncasecmp(op, "CREATE", 6))) {
+ if (mkstream) {
+ *cmd_len = REDIS_CMD_SPPRINTF(cmd, "XGROUP", "sksss", op, oplen, key, keylen,
+ arg1, arg1len, arg2, arg2len, "MKSTREAM",
+ sizeof("MKSTREAM") - 1);
+ } else {
+ *cmd_len = REDIS_CMD_SPPRINTF(cmd, "XGROUP", "skss", op, oplen, key, keylen,
+ arg1, arg1len, arg2, arg2len);
+ }
+ return SUCCESS;
} else if (argc == 4 && ((oplen == 5 && !strncasecmp(op, "SETID", 5)) ||
- (oplen == 6 && !strncasecmp(op, "CREATE", 6)) ||
(oplen == 11 && !strncasecmp(op, "DELCONSUMER", 11))))
{
*cmd_len = REDIS_CMD_SPPRINTF(cmd, "XGROUP", "skss", op, oplen, key, keylen,
arg1, arg1len, arg2, arg2len);
return SUCCESS;
- } else if (argc == 3 && ((oplen == 7 && !strncasecmp(op, "DELGROUP", 7)))) {
+ } else if (argc == 3 && ((oplen == 7 && !strncasecmp(op, "DESTROY", 7)))) {
*cmd_len = REDIS_CMD_SPPRINTF(cmd, "XGROUP", "sks", op, oplen, key,
keylen, arg1, arg1len);
return SUCCESS;