BZPOPMAX

BZPOPMAX

BZPOPMAX key timeout
Available since
5.0.0
Time complexity
O(log(N)) with N being the number of elements in the sorted set.
ACL categories
@write, @sortedset, @fast, @blocking

BZPOPMAX is the blocking variant of the sorted set ZPOPMAX primitive.

It is the blocking version because it blocks the connection when there are no members to pop from any of the given sorted sets. A member with the highest score is popped from first sorted set that is non-empty, with the given keys being checked in the order that they are given.

The timeout argument is interpreted as a double value specifying the maximum number of seconds to block. A timeout of zero can be used to block indefinitely.

See the BZPOPMIN documentation for the exact semantics, since BZPOPMAX is identical to BZPOPMIN with the only difference being that it pops members with the highest scores instead of popping the ones with the lowest scores.

Examples #

redict> DEL zset1 zset2
(integer) 0
redict> ZADD zset1 0 a 1 b 2 c
(integer) 3
redict> BZPOPMAX zset1 zset2 0
1) "zset1"
2) "c"
3) "2"

History #

6.0.0
`timeout` is interpreted as a double instead of an integer.

Redict logo courtesy of @janWilejan, CC-BY-SA-4.0. Download SVG ⤑

Portions of this website courtesy of Salvatore Sanfilippo, CC-BY-SA-4.0.