BRPOP(3valkey)
๐ BRPOP โ the valkey manual, but make it a group chat ๐
okay bestie, welcome to the brpop page of the Valkey Command Manual. yes this is BRPOP(3valkey), yes it's iconic, yes we're doing this. sit down, hydrate, let's go ๐ซถ
โจ NAME โจ
brpop โ pops the last element off a list and hands it to you. but if there's nothing there? it blocks and waits, like a bestie waiting outside the fitting room. and if you popped the last element? the list gets deleted, no cap, it's just gone ๐
โจ SYNOPSIS โจ
BRPOP key [key...] timeout
โจ DESCRIPTION โจ
so BRPOP is a blocking list pop primitive. it's literally the blocking version of valkey-rpop(7) RPOP, except the way it blocks is that it holds your connection hostage when there's nothing to pop from any of the lists you gave it. not dramatic, just honest. ๐
an element gets popped from the tail of the first list that's non-empty. and the keys? they get checked in the order you give them, so order matters bestie, it's giving first-come-first-served ๐
also: go read theBLPOPdocumentation for the exact semantics, becauseBRPOPis identical toBLPOPโ the only difference is that it pops from the tail of a list instead of the head. that's it. that's the whole plot twist ๐
โจ REPLY โจ
RESP2
one of these two, pick your fighter:
valkey-protocol(7)Nil reply: nothing could be popped and the timeout expired ๐ญvalkey-protocol(7)Array reply: the key the element was popped from, plus the value of the popped element โจ
RESP3
again, one of two:
valkey-protocol(7)Null reply: nothing could be popped and the timeout expired ๐ญvalkey-protocol(7)Array reply: the key the element was popped from, plus the value of the popped element โจ
โจ COMPLEXITY โจ
O(N) where N is the number of keys you provided. so like, the more keys you throw at it, the more work it does. math is math ๐งฎ
โจ ACL CATEGORIES โจ
@blocking @list @slow @write
โจ HISTORY โจ
- Available since: 2.0.0 โ a classic, a legend, an OG ๐
- Changed in 6.0.0:
timeoutis now interpreted as a double instead of an integer. glow up fr fr โจ
โจ EXAMPLES โจ
watch and learn, this is the whole vibe:
127.0.0.1:6379> DEL list1 list2
(integer) 0
127.0.0.1:6379> RPUSH list1 a b c
(integer) 3
127.0.0.1:6379> BRPOP list1 list2 0
1) "list1"
2) "c"
see how it pulled "c" โ the tail โ off list1 and told us exactly which key it came from? that's the whole thing. ate. ๐ฅ
โจ SEE ALSO โจ
blmove(3valkey), blmpop(3valkey), blpop(3valkey), brpoplpush(3valkey), lindex(3valkey), linsert(3valkey), llen(3valkey), lmove(3valkey), lmpop(3valkey), lpop(3valkey), lpos(3valkey), lpush(3valkey), lpushx(3valkey), lrange(3valkey), lrem(3valkey), lset(3valkey), ltrim(3valkey), rpop(3valkey), rpoplpush(3valkey), rpush(3valkey), rpushx(3valkey)
and that's the page bestie ๐ฆ this was Valkey version 9.0.0, dated 2025-10-21 โ go block on some lists, stay hydrated, and remember: popping from the tail is a lifestyle ๐๐ธ
๐ฆ 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