Mlindex
Bun

method

RedisClient.lindex

key: KeyLike,
index: number
): Promise<null | string>;

Get element at index from a list

@param key

The list key

@param index

Zero-based index (negative indexes count from the end, -1 is last element)

@returns

Promise that resolves with the element at index, or null if index is out of range

await redis.lpush("mylist", "three", "two", "one");
console.log(await redis.lindex("mylist", 0)); // "one"
console.log(await redis.lindex("mylist", -1)); // "three"
console.log(await redis.lindex("mylist", 5)); // null

Referenced types

type KeyLike = string | ArrayBufferView | Blob