ZREVRANGEBYLEX

Syntax

  1. ZREVRANGEBYLEX key max min [LIMIT offset count]

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)).

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.

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

Return

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

Examples

  1. dragonfly> ZADD myzset 0 a 0 b 0 c 0 d 0 e 0 f 0 g
  2. (integer) 7
  3. dragonfly> ZREVRANGEBYLEX myzset [c -
  4. 1) "c"
  5. 2) "b"
  6. 3) "a"
  7. dragonfly> ZREVRANGEBYLEX myzset (c -
  8. 1) "b"
  9. 2) "a"
  10. dragonfly> ZREVRANGEBYLEX myzset (g [aaa
  11. 1) "f"
  12. 2) "e"
  13. 3) "d"
  14. 4) "c"
  15. 5) "b"