BZPOPMIN(3valkey)
π BZPOPMIN β the valkey manual page, but make it cute
okay bestie, you're reading the BZPOPMIN page from the Valkey Command Manual (section 3valkey, the command-manual girlies). sit down, grab a strawberry, we're learning about blocking sorted-set pops π
β¨ NAME β¨
bzpopmin β removes and returns the member with the lowest score from one or more sorted sets. blocks until a member is available otherwise. and when it pops the last element out? it deletes the sorted set. gone. periodt. π
π SYNOPSIS π
BZPOPMIN key [key...] timeout
π¦ DESCRIPTION π¦
so. BZPOPMIN is literally the blocking variant of the sorted set ZPOPMIN primitive. that's the whole vibe.
it's the blocking version because it blocks the connection when there are no members to pop from any of the given sorted sets π like, it just sits there. waiting. main character energy, honestly. a member with the lowest score gets popped from the first sorted set that is non-empty, and the given keys are checked in the order that they are given β so order matters, bestie, don't play.
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 β³ (yes, forever. iconic.)
for the exact semantics, go read theBLPOPdocumentation, becauseBZPOPMINis identical toBLPOPβ the only difference is the data structure being popped from. that's it. that's the tea. π΅
π REPLY π
RESP2
one of the following, babes:
- 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, same energy:
- 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)) where N is the number of elements in the sorted set. fast girl behavior fr fr.
π ACL CATEGORIES π
@blocking @fast @sortedset @write
πΈ HISTORY πΈ
- Available since:
5.0.0 - Changed in
6.0.0:timeoutis 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> BZPOPMIN zset1 zset2 0
1) "zset1"
2) "a"
3) "0"
look at her go π popped "a" with score "0" from zset1 and didn't even break a sweat.
π«Ά SEE ALSO π«Ά
bzmpop(3valkey), bzpopmax(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)
and that's the whole page, bestie π§ this one's from Valkey version 9.0.0, dated 2025-10-21 β go block on a sorted set and slay π
π
π¦ 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