summaryrefslogtreecommitdiff
path: root/src/t_list.c
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2021-09-23 13:34:40 +0800
committerGitHub <noreply@github.com>2021-09-23 08:34:40 +0300
commit14d6abd8e9a928aa920d5009d79e7b8ff2d0d5ba (patch)
treef5e39738dd3570bb19fac711b0a2adfa6fdb3e5e /src/t_list.c
parent59c9716f96fbc651d4cdde734e4ec7da0d9eb815 (diff)
downloadredis-14d6abd8e9a928aa920d5009d79e7b8ff2d0d5ba.tar.gz
Add ZMPOP/BZMPOP commands. (#9484)
This is similar to the recent addition of LMPOP/BLMPOP (#9373), but zset. Syntax for the new ZMPOP command: `ZMPOP numkeys [<key> ...] MIN|MAX [COUNT count]` Syntax for the new BZMPOP command: `BZMPOP timeout numkeys [<key> ...] MIN|MAX [COUNT count]` Some background: - ZPOPMIN/ZPOPMAX take only one key, and can return multiple elements. - BZPOPMIN/BZPOPMAX take multiple keys, but return only one element from just one key. - ZMPOP/BZMPOP can take multiple keys, and can return multiple elements from just one key. Note that ZMPOP/BZMPOP can take multiple keys, it eventually operates on just on key. And it will propagate as ZPOPMIN or ZPOPMAX with the COUNT option. As new commands, if we can not pop any elements, the response like: - ZMPOP: Return a NIL in both RESP2 and RESP3, unlike ZPOPMIN/ZPOPMAX return emptyarray. - BZMPOP: Return a NIL in both RESP2 and RESP3 when timeout is reached, like BZPOPMIN/BZPOPMAX. For the normal response is nested arrays in RESP2 and RESP3: ``` ZMPOP/BZMPOP 1) keyname 2) 1) 1) member1 2) score1 2) 1) member2 2) score2 In RESP2: 1) "myzset" 2) 1) 1) "three" 2) "3" 2) 1) "two" 2) "2" In RESP3: 1) "myzset" 2) 1) 1) "three" 2) (double) 3 2) 1) "two" 2) (double) 2 ```
Diffstat (limited to 'src/t_list.c')
-rw-r--r--src/t_list.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/t_list.c b/src/t_list.c
index 4e15a819d..c1c4248d7 100644
--- a/src/t_list.c
+++ b/src/t_list.c
@@ -1104,7 +1104,7 @@ void blockingPopGenericCommand(client *c, robj **keys, int numkeys, int where, i
}
/* If the keys do not exist we must block */
- struct listPos pos = {where};
+ struct blockPos pos = {where};
blockForKeys(c,BLOCKED_LIST,keys,numkeys,count,timeout,NULL,&pos,NULL);
}
@@ -1129,7 +1129,7 @@ void blmoveGenericCommand(client *c, int wherefrom, int whereto, mstime_t timeou
addReplyNull(c);
} else {
/* The list is empty and the client blocks. */
- struct listPos pos = {wherefrom, whereto};
+ struct blockPos pos = {wherefrom, whereto};
blockForKeys(c,BLOCKED_LIST,c->argv + 1,1,0,timeout,c->argv[2],&pos,NULL);
}
} else {