BZMPOP(3valkey)
๐ 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
- fedora 44: valkey-doc 9.0.3-2.fc44 ยท CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 ยท CC-BY-SA-4.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms