Back to Redis

ZPOPMAX

content/commands/zpopmax.md

latest1.3 KB
Original Source

Removes and returns up to count members with the highest scores in the sorted set stored at key.

When left unspecified, the default value for count is 1. Specifying a count value that is higher than the sorted set's cardinality will not produce an error. When returning multiple elements, the one with the highest score will be the first, followed by the elements with lower scores.

Examples

{{% redis-cli %}} ZADD myzset 1 "one" ZADD myzset 2 "two" ZADD myzset 3 "three" ZPOPMAX myzset {{% /redis-cli %}}

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

-tab-sep-

{{< /multitabs >}}