Skip to content

Commit 37a9025

Browse files
authored
Merge pull request phpredis#1963 from phpredis/issue-1894-xpending-idle
[WIP] Issue phpredis#1894
2 parents 6aa9c08 + 28de622 commit 37a9025

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_xpending, 0, 0, 2)
680680
ZEND_ARG_INFO(0, str_end)
681681
ZEND_ARG_INFO(0, i_count)
682682
ZEND_ARG_INFO(0, str_consumer)
683+
ZEND_ARG_INFO(0, idle)
683684
ZEND_END_ARG_INFO()
684685

685686
ZEND_BEGIN_ARG_INFO_EX(arginfo_xrange, 0, 0, 3)

redis_commands.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,21 +3619,21 @@ int redis_xadd_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
36193619
return SUCCESS;
36203620
}
36213621

3622-
// XPENDING key group [start end count] [consumer]
3622+
// XPENDING key group [start end count [consumer] [idle]]
36233623
int redis_xpending_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
36243624
char **cmd, int *cmd_len, short *slot, void **ctx)
36253625
{
36263626
smart_string cmdstr = {0};
36273627
char *key, *group, *start = NULL, *end = NULL, *consumer = NULL;
36283628
size_t keylen, grouplen, startlen, endlen, consumerlen;
36293629
int argc;
3630-
zend_long count = -1;
3630+
zend_long count = -1, idle = 0;
36313631

36323632
// XPENDING mystream group55 - + 10 consumer-123
3633-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|ssls", &key,
3633+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|sslsl", &key,
36343634
&keylen, &group, &grouplen, &start, &startlen,
3635-
&end, &endlen, &count, &consumer, &consumerlen)
3636-
== FAILURE)
3635+
&end, &endlen, &count, &consumer, &consumerlen,
3636+
&idle) == FAILURE)
36373637
{
36383638
return FAILURE;
36393639
}
@@ -3643,8 +3643,8 @@ int redis_xpending_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
36433643
return FAILURE;
36443644
}
36453645

3646-
/* Calculate argc. It's either 2, 5, or 6 */
3647-
argc = 2 + (start != NULL ? 3 + (consumer != NULL) : 0);
3646+
/* Calculate argc. It's either 2, 5, 6 or 7 */
3647+
argc = 2 + (start != NULL ? 3 + (consumer != NULL) + (idle != 0) : 0);
36483648

36493649
/* Construct command and add required arguments */
36503650
REDIS_CMD_INIT_SSTR_STATIC(&cmdstr, argc, "XPENDING");
@@ -3653,6 +3653,10 @@ int redis_xpending_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
36533653

36543654
/* Add optional argumentst */
36553655
if (start) {
3656+
if (idle != 0) {
3657+
REDIS_CMD_APPEND_SSTR_STATIC(&cmdstr, "IDLE");
3658+
redis_cmd_append_sstr_long(&cmdstr, (long)idle);
3659+
}
36563660
redis_cmd_append_sstr(&cmdstr, start, startlen);
36573661
redis_cmd_append_sstr(&cmdstr, end, endlen);
36583662
redis_cmd_append_sstr_long(&cmdstr, (long)count);

0 commit comments

Comments
 (0)