Redis Commands - Sorted Sets - zrevrangebylex

 

original

http://redis.io/commands/zrevrangebylex

 

Introduction

Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings.

 

According to the dictionary range, returns the elements within a certain range in the sorted set, from high to low according to the string.

 

grammar

ZREVRANGEBYLEX key max min [LIMIT offset count]

 

Version

Available since 2.8.9.

 

Available since version 2.8.9.

 

time complexity

Time complexity: O(log(N)+M) with N being the number of elements in the sorted set and M the number of elements being returned. If M is constant (e.g. always asking for the first 10 elements with LIMIT), you can consider it O(log(N)).

 

O(log(N)+M): N is the number of elements in the sorted set and M is the number of elements returned. If M is constant, you can consider the time complexity to be O(log(N)).

 

describe

When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between max and min.

 

To enforce lexicographic ordering when all elements inserted in the sorted set have the same score, this command returns all elements with values ​​between max and min.

 

Apart from the reversed ordering, ZREVRANGEBYLEX is similar to ZRANGEBYLEX.

 

ZREVRANGEBYLEX is similar to ZRANGEBYLEX except that the order is reversed.

 

return value

Array reply: list of elements in the specified score range.

 

Array: A list of elements of the specified range.

 

example

redis>  ZADD myzset 0 a 0 b 0 c 0 d 0 e 0 f 0 g
(integer) 7
redis>  ZREVRANGEBYLEX myzset [c -
1) "c"
2) "b"
3) "a"
redis>  ZREVRANGEBYLEX myzset (c -
1) "b"
2) "a"
redis>  ZREVRANGEBYLEX myzset (g [aaa
1) "f"
2) "e"
3) "d"
4) "c"
5) "b"
redis>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326955628&siteId=291194637