method
RedisClient.zintercard
numkeys: number,
): Promise<number>;
Count the number of members in the intersection of multiple sorted sets
Computes the cardinality of the intersection of the sorted sets at the specified keys. The intersection includes only elements that exist in all of the given sorted sets.
When a LIMIT is provided, the command stops counting once the limit is reached, which is useful for performance when you only need to know if the cardinality exceeds a certain threshold.
@param numkeys
The number of sorted set keys
@param keys
The sorted set keys to intersect
@returns
Promise that resolves with the number of elements in the intersection
await redis.send("ZADD", ["zset1", "1", "one", "2", "two", "3", "three"]);
await redis.send("ZADD", ["zset2", "1", "one", "2", "two", "4", "four"]);
const count = await redis.zintercard(2, "zset1", "zset2");
console.log(count); // 2 (one, two)numkeys: number,
): Promise<number>;
Count the number of members in the intersection with a limit
@param numkeys
The number of sorted set keys
@returns
Promise that resolves with the number of elements (up to limit)
await redis.send("ZADD", ["zset1", "1", "a", "2", "b", "3", "c"]);
await redis.send("ZADD", ["zset2", "1", "a", "2", "b", "3", "c"]);
const count = await redis.zintercard(2, "zset1", "zset2", "LIMIT", 2);
console.log(count); // 2 (stopped at limit)Referenced types
type KeyLike = string | ArrayBufferView | Blob