ZRANGEBYLEX command in redis

ZRANGEBYLEX key min max [LIMIT offset count]

Returns a range of members in a sorted set, by lexicographical range.

Redis ZRANGEBYLEX command returns the specified range of elements in the sorted set stored at the key.

The elements are considered to be ordered from the lowest to the highest score. Lexicographical order is used for elements with an equal score.

Both start and stop are zero-based indexes, where 0 is the first element, 1 is the next element, and so on. They can also be negative numbers indicating offsets from the end of the sorted set, with -1 being the last element of the sorted set, -2 the penultimate element, and so on.

Return Value

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

Syntax:

ZRANGEBYLEX key min max

Example

redis:6379> ZADD mykey 0 A 2 C 3 D 1 E
(integer) 4
redis:6379> ZRANGEBYLEX mykey - (E
1) "A"
redis:6379> ZRANGEBYLEX mykey - [E
1) "A"
2) "E"
3) "C"
4) "D"



No comments:

Post a Comment