Easy Tutorial
❮ Keys Expire Hashes Hmset ❯

Redis Zrangebylex Command

Redis Sorted Set

Redis Zrangebylex returns members of a sorted set by lexicographical range.

Syntax

The basic syntax of the redis Zrange command is as follows:

redis 127.0.0.1:6379> ZRANGEBYLEX key min max [LIMIT offset count]

Available Versions

= 2.8.9

Return Value

A list of elements within the specified range.

Example

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

Redis Sorted Set

❮ Keys Expire Hashes Hmset ❯