Back to Redis

BZMPOP

content/commands/bzmpop.md

latest2.4 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 >}}

BZMPOP is the blocking variant of [ZMPOP]({{< relref "/commands/zmpop" >}}).

When any of the sorted sets contains elements, this command behaves exactly like [ZMPOP]({{< relref "/commands/zmpop" >}}). When used inside a [MULTI]({{< relref "/commands/multi" >}})/[EXEC]({{< relref "/commands/exec" >}}) block or a Lua script, this command behaves exactly like [ZMPOP]({{< relref "/commands/zmpop" >}}). When all sorted sets are empty, Redis will block the connection until another client adds members to one of the keys or until the timeout (a double value specifying the maximum number of seconds to block) elapses. A timeout of zero can be used to block indefinitely.

See [ZMPOP]({{< relref "/commands/zmpop" >}}) for more information.

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="bzmpop-return-info" tab1="RESP2" tab2="RESP3" >}}

One of the following:

  • Nil reply: when no element could be popped.
  • Array reply: a two-element array with the first element being the name of the key from which elements were popped, and the second element is an array of the popped elements. Every entry in the elements array is also an array that contains the member and its score.

-tab-sep-

One of the following:

  • Null reply: when no element could be popped.
  • Array reply: a two-element array with the first element being the name of the key from which elements were popped, and the second element is an array of the popped elements. Every entry in the elements array is also an array that contains the member and its score.

{{< /multitabs >}}