Use BZPOPMIN to pop the lowest-scoring member from the first non-empty sorted set, blocking until one has a member or the timeout expires.
It is the blocking form of ZPOPMIN and accepts several keys, checked in the order given, with the reply naming the key the member came from along with the member and its score.
The timeout is in seconds, may be fractional, and 0 waits indefinitely; when it expires the reply is null. Since the lowest score is popped first, a set scored by timestamp or priority number becomes a queue that hands out the most urgent item to whichever worker is waiting.
Syntax#
Arguments#
| Argument | Required | Repeatable | Description |
|---|---|---|---|
<key> | Yes | Yes | Redis key targeted by the command. |
<timeout> | Yes | No | Seconds 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.
| Protocol | Reply |
|---|---|
| RESP2 | Null bulk string or null array, or three-element key/member/score array |
| RESP3 | Null, or three-element key/member/score array |
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
This command is not supported yet in @upstash/redis.
upstash_redis
This command is not supported yet in upstash_redis.