Back to Redis

ZREVRANGE

content/commands/zrevrange.md

latest1.4 KB
Original Source

Returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score.

Apart from the reversed ordering, ZREVRANGE is similar to [ZRANGE]({{< relref "/commands/zrange" >}}).

Examples

{{% redis-cli %}} ZADD myzset 1 "one" ZADD myzset 2 "two" ZADD myzset 3 "three" ZREVRANGE myzset 0 -1 ZREVRANGE myzset 2 3 ZREVRANGE myzset -2 -1 {{% /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> | Deprecated as of Redis v6.2.0. |

Return information

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

  • Array reply: a list of members in the specified range, optionally with their scores if WITHSCORE was used.

-tab-sep-

  • Array reply: a list of members in the specified range, optionally with their scores if WITHSCORE was used.

{{< /multitabs >}}