English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Zrevrange Command

Redis Sorted Sets (sorted set)

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

Members are sorted by position in descending order (from largest to smallest) by score value.

Members with the same score value are sorted in reverse lexicographical order.

Other than the members are sorted in descending order by score value, the ZREVRANGE command is similar to ZRANGE commands are the same.

Syntax

The basic syntax of 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

List of members of the sorted set within a specified range, with optional score values.

Online Examples

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

Redis Sorted Sets (sorted set)