BZMPOP(3valkey)

๐Ÿ“ฆ
version 9.0.6 ยท 2 versions
, in fedora 44

๐Ÿ’– BZMPOP โ€” the blocking glow-up of ZMPOP ๐Ÿ’–

okay bestie, this is bzmpop from the Valkey Command Manual, and she is literally the patient one of the sorted-set squad. sit down, grab a strawberry, let's get into it ๐Ÿ“โœจ


๐ŸŒธ NAME ๐ŸŒธ

bzmpop โ€” removes and returns a member by score from one or more sorted sets. blocks until a member is available otherwise. deletes the sorted set if the last element was popped. yeah, she's dramatic AND thorough ๐Ÿ’…


โœจ SYNOPSIS โœจ

BZMPOP timeout numkeys key [key...]  <MIN | MAX> [COUNT count]

that's the whole vibe. keep scrolling tho, the details are giving ๐Ÿซถ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so BZMPOP is the blocking variant of ZMPOP. like, same energy, but she'll wait for you. main character behavior, honestly ๐Ÿ‘‘

when any of the sorted sets contains elements, this command behaves exactly like ZMPOP. no cap, identical.

when used inside a MULTI/EXEC block, this command behaves exactly like ZMPOP too. inside a transaction she does NOT block, she just does the thing. periodt.

when all sorted sets are empty, Valkey will block the connection until another client adds members to one of the keys, or until the timeout elapses. and what is that timeout, you ask? it's a double value specifying the maximum number of seconds to block. so yes, decimals are allowed, she's precise like that ๐Ÿ’…

๐Ÿšจ a timeout of zero can be used to block indefinitely. like, forever. no takebacks. she will simply wait. iconic but also, bestie, be careful ๐Ÿ˜ญ

see ZMPOP for more information โ€” she's the non-blocking sister, iykyk.


๐Ÿ’Œ REPLY ๐Ÿ’Œ

๐ŸŒˆ RESP2

one of the following:

  • valkey-protocol(7) Nil reply: when no element could be popped. sad girl hours ๐Ÿ˜”
  • valkey-protocol(7) Array reply: a two-element array with the first element being the name of the key from which elements were popped, and the second element is an array of the popped elements. every entry in the elements array is also an array that contains the member and its score. nested arrays, nested blessings โœจ

๐ŸŒˆ RESP3

one of the following:

  • valkey-protocol(7) Null reply: when no element could be popped. same sadness, different protocol ๐Ÿ’€
  • valkey-protocol(7) Array reply: a two-element array with the first element being the name of the key from which elements were popped, and the second element is an array of the popped elements. every entry in the elements array is also an array that contains the member and its score. yes it's the same shape, RESP3 just calls the empty case a Null reply instead of Nil, she's fancy like that ๐ŸŽ€

๐Ÿ”ฅ COMPLEXITY ๐Ÿ”ฅ

O(K) + O(M*log(N))

where K is the number of provided keys, N being the number of elements in the sorted set, and M being the number of elements popped. math girlies rise ๐Ÿงฎ๐Ÿ’œ


๐Ÿ‘‘ ACL CATEGORIES ๐Ÿ‘‘

@blocking @slow @sortedset @write

she blocks, she's slow (affectionately), she's a sortedset situation, and she writes. four for four, slay ๐ŸŒŸ


๐Ÿ“œ HISTORY ๐Ÿ“œ

  • available since: 7.0.0 โ€” a modern queen, born in the 7 era ๐ŸŽ‚

๐Ÿซถ SEE ALSO ๐Ÿซถ

bzpopmax(3valkey), bzpopmin(3valkey), zadd(3valkey), zcard(3valkey), zcount(3valkey), zdiff(3valkey), zdiffstore(3valkey), zincrby(3valkey), zinter(3valkey), zintercard(3valkey), zinterstore(3valkey), zlexcount(3valkey), zmpop(3valkey), zmscore(3valkey), zpopmax(3valkey), zpopmin(3valkey), zrandmember(3valkey), zrange(3valkey), zrangebylex(3valkey), zrangebyscore(3valkey), zrangestore(3valkey), zrank(3valkey), zrem(3valkey), zremrangebylex(3valkey), zremrangebyrank(3valkey), zremrangebyscore(3valkey), zrevrange(3valkey), zrevrangebylex(3valkey), zrevrangebyscore(3valkey), zrevrank(3valkey), zscan(3valkey), zscore(3valkey), zunion(3valkey), zunionstore(3valkey)

that's the whole sorted-set friend group, go say hi to all of them, they're all so valid ๐Ÿ’–


and that's the tea, bestie โœจ this was bzmpop from Valkey version 9.0.0, dated 2025-10-21 โ€” mwah, go pop something, ily ๐Ÿซถ๐Ÿ’…

๐Ÿ“ฆ where this page comes from