Conversation
This is similar to the previous LMPOP/BLMPOP, except for 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 is the same as before:
- ZMPOP: Return an emptyarray in both RESP2 and RESP3, like ZPOPMIN/ZPOPMAX.
- 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
```
|
Some background on the response format. First, like ZPOPMIN we can't use a RESP3 map since the order matters. |
I'm not sure it's wise for ZMPOP to return an empty array when it can't pop, i think it should return NIL like the new LMPOP. |
oranagra
left a comment
There was a problem hiding this comment.
looks good. obviously missing tests..
Co-authored-by: Oran Agra <[email protected]>
madolson
left a comment
There was a problem hiding this comment.
API looks good, this looks like it still needs tests as Oran mentioned.
|
Look like i added a bunch of test code again... |
Co-authored-by: Oran Agra <[email protected]>
oranagra
left a comment
There was a problem hiding this comment.
@redis/core-team please approve the new commands.
@enjoy-binbin please make a redis-doc PR
|
triggered a partial CI on all platforms: https://github.com/redis/redis/actions/runs/1250894823 |
The previous code did not check whether COUNT is set. So we can use `lmpop 2 key1 key2 left count 1 count 2`. This situation can occur in LMPOP/BLMPOP/ZMPOP/BZMPOP commands. LMPOP/BLMPOP introduced in redis#9373, ZMPOP/BZMPOP introduced in redis#9484.
This bug was introduced in redis#9484 (7.0.0). It result that BZMPOP blocked on non-key arguments. Like `bzmpop 0 1 myzset min count 10`, this command will additionally block in these keys (except for the first and the last argument): - 0: timeout value - 1: numkeys value - min: min/max token - count: count token Fixes redis#10762
This bug was introduced in #9484 (7.0.0). It result that BZMPOP blocked on non-key arguments. Like `bzmpop 0 1 myzset min count 10`, this command will additionally block in these keys (except for the first and the last argument) and can return their values: - 0: timeout value - 1: numkeys value - min: min/max token - count: count token
This bug was introduced in redis#9484 (7.0.0). It result that BZMPOP blocked on non-key arguments. Like `bzmpop 0 1 myzset min count 10`, this command will additionally block in these keys (except for the first and the last argument) and can return their values: - 0: timeout value - 1: numkeys value - min: min/max token - count: count token
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:
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:
For the normal response is nested arrays in RESP2 and RESP3: