Mblmpop
Bun

method

RedisClient.blmpop

timeout: number,
numkeys: number,
...args: string | number[]
): Promise<null | [string, string[]]>;

Blocking pop multiple elements from lists

Blocks until an element is available from one of the specified lists or the timeout expires. Can pop from the LEFT or RIGHT end and optionally pop multiple elements at once using COUNT.

@param timeout

Timeout in seconds (can be fractional, 0 = block indefinitely)

@param numkeys

Number of keys that follow

@param args

Keys, direction ("LEFT" or "RIGHT"), and optional COUNT modifier

@returns

Promise that resolves with [key, [elements]] or null on timeout

// Pop from left end of first available list, wait 1 second
const result = await redis.blmpop(1.0, 2, "list1", "list2", "LEFT");
if (result) {
  const [key, elements] = result;
  console.log(`Popped from ${key}: ${elements.join(", ")}`);
}

// Pop 3 elements from right end
const result2 = await redis.blmpop(0.5, 1, "mylist", "RIGHT", "COUNT", 3);
// Returns: ["mylist", ["elem1", "elem2", "elem3"]] or null if timeout