Mlset
Bun

method

RedisClient.lset

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

Set element at index in a list

@param key

The list key

@param index

Zero-based index (negative indexes count from the end)

@param element

The value to set

@returns

Promise that resolves with "OK" on success

await redis.lpush("mylist", "three", "two", "one");
await redis.lset("mylist", 0, "zero");
console.log(await redis.lrange("mylist", 0, -1)); // ["zero", "two", "three"]
await redis.lset("mylist", -1, "last");
console.log(await redis.lrange("mylist", 0, -1)); // ["zero", "two", "last"]

Referenced types

type KeyLike = string | ArrayBufferView | Blob