BZPOPMAX(3valkey)

πŸ“¦
version 9.0.6 Β· 2 versions
, in fedora 44

πŸ’– BZPOPMAX πŸ’–

okay bestie, welcome to the Valkey Command Manual entry for bzpopmax β€” she's a whole main character and she's about to hand you the highest-scoring member of a sorted set like it's nothing πŸŽ€


✨ NAME ✨

bzpopmax β€” removes and returns the member with the highest score from one or more sorted sets. Blocks until a member is available, otherwise. Deletes the sorted set if the last element was popped. πŸ¦‹


✨ SYNOPSIS ✨

BZPOPMAX key [key...] timeout

✨ DESCRIPTION ✨

so BZPOPMAX is literally the blocking variant of the sorted set ZPOPMAX primitive. same energy, just with ✨patience✨

she's the blocking version because she blocks the connection when there are no members to pop from any of the given sorted sets. no cap. a member with the highest score gets popped from the first sorted set that is non-empty, and the keys you gave her are checked in the order that they are given. first come, first served, periodt πŸ’…

the timeout argument is interpreted as a double value specifying the maximum number of seconds to block. a timeout of 0 can be used to block indefinitely β€” she will literally wait forever for you, that's devotion 🫢

πŸ’€ heads up: see the BZPOPMIN documentation for the exact semantics, because 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. iykyk.

✨ REPLY ✨

RESP2

one of the following, bestie:

  • valkey-protocol(7) Nil reply: when no element could be popped and the timeout expired. 😭
  • valkey-protocol(7) Array reply: the keyname, popped member, and its score. πŸ‘‘

RESP3

one of the following, bestie:

  • valkey-protocol(7) Null reply: when no element could be popped and the timeout expired. 😭
  • valkey-protocol(7) Array reply: the keyname, popped member, and its score. πŸ‘‘

✨ COMPLEXITY ✨

O(log(N)) with N being the number of elements in the sorted set. fast girlie behaviour fr fr ⭐


✨ ACL CATEGORIES ✨

@blocking @fast @sortedset @write


✨ HISTORY ✨

  • Available since: 5.0.0 🌸
  • Changed in 6.0.0: timeout is interpreted as a double instead of an integer. glow up ✨

✨ EXAMPLES ✨

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

look at her go πŸ’… "c" with the score 2 β€” highest score, popped, iconic, no notes πŸ”₯


✨ SEE ALSO ✨


and that's the whole page, bestie!! 🧚 this was page BZPOPMAX(3valkey) from the Valkey Command Manual, version 9.0.0, dated 2025-10-21 β€” go block on something, love u, bye πŸ’œπŸ“

πŸ“¦ where this page comes from