Easy Tutorial
❮ Sorted Sets Zremrangebyrank Lists Rpushx ❯

Redis Zrevrange Command

Redis Sorted Set

The Redis Zrevrange command returns members within a specified range in a sorted set.

Members are ordered by their score values in descending (from largest to smallest) order.

Members with the same score value are ordered by reverse lexicographical order.

Except for the members being ordered by score values in descending order, the ZREVRANGE command is the same as the ZRANGE command in other aspects.

Syntax

The basic syntax for the redis Zrevrange command is as follows:

redis 127.0.0.1:6379> ZREVRANGE key start stop [WITHSCORES]

Available Versions

= 1.2.0

Return Value

A list of sorted set members within the specified range, with optional scores.

Example

redis 127.0.0.1:6379> ZRANGE salary 0 -1 WITHSCORES        # Ascending order
1) "peter"
2) "3500"
3) "tom"
4) "4000"
5) "jack"
6) "5000"

redis 127.0.0.1:6379> ZREVRANGE salary 0 -1 WITHSCORES     # Descending order
1) "jack"
2) "5000"
3) "tom"
4) "4000"
5) "peter"
6) "3500"

Redis Sorted Set

❮ Sorted Sets Zremrangebyrank Lists Rpushx ❯