Returns the specified range of elements in the sorted set stored at
The elements are considered to be ordered from the lowest to the highest score.
Lexicographical order is used for elements with equal score.
See ZREVRANGE when you need the elements ordered from highest to lowest score (and descending lexicographical order for elements with equal score).
stop are zero-based indexes, where
0 is the first element,
1 is the next element and so on.
They can also be negative numbers indicating offsets from the end of the sorted
-1 being the last element of the sorted set,
-2 the penultimate
element and so on.
Out of range indexes will not produce an error.
start is larger than the largest index in the sorted set, or
stop, an empty list is returned.
stop is larger than the end of the sorted set Redis will treat it like it
is the last element of the sorted set.
It is possible to pass the
WITHSCORES option in order to return the scores of
the elements together with the elements.
The returned list will contain
value1,score1,...,valueN,scoreN instead of
Client libraries are free to return a more appropriate data type (suggestion: an
array with (value, score) arrays/tuples).
Multi-bulk reply: list of elements in the specified range (optionally with their scores).
(integer) 1redis> ZADD myzset 2 "two"
(integer) 1redis> ZADD myzset 3 "three"
(integer) 1redis> ZRANGE myzset 0 -1
1) "one" 2) "two" 3) "three"redis> ZRANGE myzset 2 3
1) "three"redis> ZRANGE myzset -2 -1
1) "two" 2) "three"