Returns if member is a member of the set stored at key.
Usage
await redis.sismember(key, member);
Parameters
The member to check for existence in the set
Response
Returns 1 if the member exists in the set, 0 otherwise
Examples
Check if member exists
await redis.sadd("myset", "hello", "world");
const exists = await redis.sismember("myset", "hello");
console.log(exists); // 1
Check for non-existing member
await redis.sadd("myset", "hello", "world");
const exists = await redis.sismember("myset", "foo");
console.log(exists); // 0
Using in conditionals
const isMember = await redis.sismember("users:premium", "user:123");
if (isMember === 1) {
console.log("User has premium access");
} else {
console.log("User does not have premium access");
}
Check membership with custom types
await redis.sadd("numbers", 1, 2, 3, 4, 5);
const exists = await redis.sismember("numbers", 3);
console.log(exists); // 1