English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Redis Sorted Sets (sorted set)
Redis Zrange gibt die Mitglieder im angegebenen Intervall des geordneten Sets zurück.
Die Positionen der Mitglieder werden nach zunehmendem Wert (von klein nach groß) sortiert.
Mitglieder mit gleicher Punktzahl nach alphabetischer Reihenfolge (lexicographical order) sortieren möchten.
Wenn Sie die Mitglieder nach
Sorte nach abnehmendem Wert (von groß nach klein), bitte verwenden ZREVRANGE command.
The index parameters start and stop are both base 0, which means that 0 represents the first member of the sorted set, and 1 to represent the second member, and so on.
You can also use negative indices, with -1 represents the last member, -2 represents the second-to-last member, and so on.
The basic syntax of the redis Zrange command is as follows:
redis 127.0.0.1:6379> ZRANGE key start stop [WITHSCORES]
>= 1.2.0
List of sorted set members within the specified range, with score values (optional).
redis 127.0.0.1:6379> ZRANGE salary 0 -1 WITHSCORES # Display the entire member list of the sorted set 1)"jack" 2)"35" 3)"tom" 4)"5" 5)"boss" 6)"10086" redis 127.0.0.1:6379> ZRANGE salary 1 2 WITHSCORES # Display the member list of the index range of the sorted set 1 to 2 member 1)"tom" 2)"5" 3)"boss" 4)"10086" redis 127.0.0.1:6379> ZRANGE salary 0 200000 WITHSCORES # Test when the end index exceeds the maximum index 1)"jack" 2)"35" 3)"tom" 4)"5" 5)"boss" 6)"10086" redis > ZRANGE salary 200000 3000000 WITHSCORES # Test when the given range does not exist in the sorted set (empty list or set)