Mzrangebylex
Bun

method

RedisClient.zrangebylex

key: KeyLike,
min: string,
max: string
): Promise<string[]>;

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:

  • [member for inclusive lower bound
  • (member for exclusive lower bound
  • - for negative infinity
  • + for positive infinity
@param key

The sorted set key (all members must have the same score)

@param min

Minimum lexicographical value (use "-" for negative infinity, "[" or "(" for inclusive/exclusive)

@param max

Maximum lexicographical value (use "+" for positive infinity, "[" or "(" for inclusive/exclusive)

@returns

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"]
key: KeyLike,
min: string,
max: string,
limit: 'LIMIT',
offset: number,
count: number
): Promise<string[]>;

Return members in a sorted set within a lexicographical range, with pagination

@param key

The sorted set key

@param min

Minimum lexicographical value

@param max

Maximum lexicographical value

@param limit

The "LIMIT" keyword

@param offset

The number of elements to skip

@param count

The maximum number of elements to return

@returns

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"]
key: KeyLike,
min: string,
max: string,
...options: string | number[]
): Promise<string[]>;

Return members in a sorted set within a lexicographical range, with options

@param key

The sorted set key

@param min

Minimum lexicographical value

@param max

Maximum lexicographical value

@param options

Additional options (LIMIT offset count)

@returns

Promise that resolves with array of members

Referenced types

type KeyLike = string | ArrayBufferView | Blob