Back to Redis

BZPOPMIN

content/commands/bzpopmin.md

latest2.2 KB
Original Source

{{< note >}} This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. {{< /note >}}

BZPOPMIN is the blocking variant of the sorted set [ZPOPMIN]({{< relref "/commands/zpopmin" >}}) primitive.

It is the blocking version because it blocks the connection when there are no members to pop from any of the given sorted sets. A member with the lowest score is popped from first sorted set that is non-empty, with the given keys being checked in the order that they are given.

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.

See the BLPOP documentation for the exact semantics, since BZPOPMIN is identical to [BLPOP]({{< relref "/commands/blpop" >}}) with the only difference being the data structure being popped from.

Examples

redis> DEL zset1 zset2
(integer) 0
redis> ZADD zset1 0 a 1 b 2 c
(integer) 3
redis> BZPOPMIN zset1 zset2 0
1) "zset1"
2) "a"
3) "0"

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |

Return information

{{< multitabs id="bzpopmin-return-info" tab1="RESP2" tab2="RESP3" >}}

One of the following:

  • Nil reply: when no element could be popped and the timeout expired.
  • Array reply: the keyname, popped member, and its score.

-tab-sep-

One of the following:

  • Null reply: when no element could be popped and the timeout expired.
  • Array reply: the keyname, popped member, and its score.

{{< /multitabs >}}