Mlrem
Bun

method

RedisClient.lrem

key: KeyLike,
count: number,
element: KeyLike
): Promise<number>;

Remove elements from a list

@param key

The list key

@param count

Number of elements to remove

  • count > 0: Remove count occurrences from head to tail
  • count < 0: Remove count occurrences from tail to head
  • count = 0: Remove all occurrences
@param element

The element to remove

@returns

Promise that resolves with the number of elements removed

await redis.rpush("mylist", "hello", "hello", "world", "hello");
await redis.lrem("mylist", 2, "hello"); // Removes first 2 "hello"
// List is now: ["world", "hello"]

Referenced types

type KeyLike = string | ArrayBufferView | Blob