ZRANGEBYLEX
Deprecated: use ZRANGE instead.
ZRANGEBYLEX key min max [LIMIT offset count]
- Group
- Sorted set
- Complexity
- O(log(N)+M) where N is the size of the sorted set and M is the number of members returned
- Arity
- -4 (at least 4 words, counting the command name)
- Flags
- read-only
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
ZRANGEBYLEX returns the members of the sorted set at key that fall between
min and max in byte-wise lexicographic order, smallest first. It is meant
for sorted sets where every member has the same score. It is the same as
ZRANGE key min max BYLEX; new code can use ZRANGE.
Each bound must be [value (inclusive), (value (exclusive), - (lowest
possible) or + (highest possible).
Options
Section titled “Options”| Option | Effect |
|---|---|
LIMIT offset count |
Skip offset matching members, then return at most count. A negative count returns all remaining members. |
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Success | Array of members | Same |
| Key does not exist or nothing in range | Empty array | Same |
Errors:
ERR min or max not valid string range itemfor a bad bound.ERR syntax error, WITHSCORES not supported in combination with BYLEXif you passWITHSCORES.ERR syntax errorfor another unknown option, andERR value is not an integer or out of rangefor a non-integerLIMITvalue.WRONGTYPEifkeyholds a value that is not a sorted set.
Examples
Section titled “Examples”127.0.0.1:6379> ZADD names 0 "ann" 0 "bob" 0 "cat" 0 "dan"(integer) 4127.0.0.1:6379> ZRANGEBYLEX names [b (d1) "bob"2) "cat"127.0.0.1:6379> ZRANGEBYLEX names - + LIMIT 2 51) "cat"2) "dan"Compatibility
Section titled “Compatibility”Same as Redis 7.4 and Valkey 8, where it is also deprecated in favour of
ZRANGE ... BYLEX.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.