method
RedisClient.zrangebylex
Return members in a sorted set within a lexicographical range
When all the elements in a sorted set have the same score, this command returns the elements between min and max in lexicographical order.
Lex ranges:
[memberfor inclusive lower bound(memberfor exclusive lower bound-for negative infinity+for positive infinity
The sorted set key (all members must have the same score)
Minimum lexicographical value (use "-" for negative infinity, "[" or "(" for inclusive/exclusive)
Maximum lexicographical value (use "+" for positive infinity, "[" or "(" for inclusive/exclusive)
Promise that resolves with array of members
await redis.send("ZADD", ["myzset", "0", "apple", "0", "banana", "0", "cherry"]);
const members = await redis.zrangebylex("myzset", "[banana", "[cherry");
// Returns: ["banana", "cherry"]Return members in a sorted set within a lexicographical range, with pagination
The sorted set key
Minimum lexicographical value
Maximum lexicographical value
The "LIMIT" keyword
The number of elements to skip
The maximum number of elements to return
Promise that resolves with array of members
await redis.send("ZADD", ["myzset", "0", "a", "0", "b", "0", "c", "0", "d"]);
const result = await redis.zrangebylex("myzset", "-", "+", "LIMIT", 1, 2);
// Returns: ["b", "c"]Return members in a sorted set within a lexicographical range, with options
The sorted set key
Minimum lexicographical value
Maximum lexicographical value
Additional options (LIMIT offset count)
Promise that resolves with array of members