ZRANGEBYLEX

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Query members in a lexicographical range

Usage: zrangebylex key min max.
min and max are member bounds. Use -, + to query all members.
When specifying values for min/max, prefix them with [ or (.
Use [ to include the value and ( to exclude it.
This command requires all scores to be equal to get the intended result.
This command has no withscores option.

Example

Command>zrangebylex city - +
Result> 0) Beijing
1) New Delhi
2) New York
3) Seoul
Command>zrangebylex city "[New Delhi" +
Result> 0) New Delhi
1) New York
2) Seoul
Command>zrangebylex city "(New Delhi" +
Result> 0) New York
1) Seoul
Command>zrangebylex city "(New Delhi" "(Seoul"
Result> 0) New York

View animation


Using limit offset count

Usage: zrangebylex key min max limit offset count.
offset is the starting point, and count is the number of members to return.
offset can start from 0, and count must be 1 or greater. If count is 0, nothing is returned.
If limit is used, both offset and count are required.
Useful for paging.<

Example

Command>zrangebylex city - + limit 0 2
Result> 0) Beijing
1) New Delhi
Command>zrangebylex city - + limit 2 2
Result> 0) New York
1) Seoul

View animation



Syntax

ZRANGEBYLEX key min max [limit offset count]

  • Available since version 2.8.9.
  • Time complexity is O(log(N)+M). N is the number of members in the set, and, M is the number of members returned.
Related commands ZRANGE, ZREVRANGE, ZREVRANGEBYSCORE, LRANGE
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< ZREVRANGEBYSCORE ZRANGEBYLEX ZREVRANGEBYLEX >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.