Mlinsert
Bun

method

RedisClient.linsert

key: KeyLike,
position: 'BEFORE' | 'AFTER',
pivot: KeyLike,
element: KeyLike
): Promise<number>;

Insert an element before or after another element in a list

@param key

The list key

@param position

"BEFORE" or "AFTER" to specify where to insert

@param pivot

The pivot element to insert before or after

@param element

The element to insert

@returns

Promise that resolves with the length of the list after insert, -1 if pivot not found, or 0 if key doesn't exist

await redis.lpush("mylist", "World");
await redis.lpush("mylist", "Hello");
await redis.linsert("mylist", "BEFORE", "World", "There");
// List is now: ["Hello", "There", "World"]

Referenced types

type KeyLike = string | ArrayBufferView | Blob