Arguments
string
required
The key of the set.
number
default:1
How many members to remove and return.
Response
The popped member.
If
count is specified, an array of members is returned.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
await redis.sadd("set", "a", "b", "c");
const popped = await redis.spop("set");
console.log(popped); // "a"
await redis.sadd("set", "a", "b", "c");
const popped = await redis.spop("set", 2);
console.log(popped); // ["a", "b"]
Removes and returns one or more random members from a set.
count is specified, an array of members is returned.await redis.sadd("set", "a", "b", "c");
const popped = await redis.spop("set");
console.log(popped); // "a"
await redis.sadd("set", "a", "b", "c");
const popped = await redis.spop("set", 2);
console.log(popped); // ["a", "b"]
Was this page helpful?