Upstash Documentation

BRPOP

Pop from the tail of a list, blocking until an element arrives.
2 min read

Use BRPOP to pop an element from the tail of the first non-empty list, blocking until one has an element or the timeout expires.

It is the blocking form of RPOP and behaves like BLPOP in every other respect: several keys are checked in the order given, the reply names the key the element came from, the timeout is in seconds and may be fractional with 0 meaning wait forever, and clients blocked on the same key are served in the order they started waiting.

Producers pushing with LPUSH and consumers waiting with BRPOP form the classic first-in, first-out worker queue.

Syntax#

Arguments#

ArgumentRequiredRepeatableDescription
<key>YesYesRedis key targeted by the command.
<timeout>YesNoSeconds to block; 0 blocks indefinitely.

Important points#

  • A blocking form holds the request until data arrives or its timeout expires. Set the client/network timeout longer than the command timeout.

Response#

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.

ProtocolReply
RESP2Null bulk string or null array, or two-element key/value array
RESP3Null, or two-element key/value array
Note

Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples#

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Redis CLI
@upstash/redis
Note

This command is not supported yet in @upstash/redis.

upstash_redis
Note

This command is not supported yet in upstash_redis.

ioredis
node-redis
redis-py
go-redis
jedis
redis-rs