SDIFFCARD to count the members of the first set that are not present in any of the other sets. It returns only the count; use SDIFF to retrieve the members.
Keys that do not exist count as empty sets, so a missing first key returns 0. The command does not modify the source sets or store the difference.
LIMIT stops counting once that many members have been found and returns the limit. For example, LIMIT 1 checks whether the difference contains any members. Omitting LIMIT or using LIMIT 0 returns the full count.
Syntax
Arguments
Important points
numkeysmust equal the number of key arguments that immediately follow it.- Key order matters: the command subtracts the other sets from the first set.
- With one key, the command returns that set’s cardinality, capped by a positive
LIMIT.
Response
The number of members in the difference, capped byLIMIT when it is positive.
Examples
TCP examples use the TLSREDIS_URL from the Upstash console. Client examples query set1 and set2 from the Redis CLI example.
Redis CLI
Redis CLI
a and b, so its cardinality is 2.@upstash/redis
@upstash/redis
This command is not supported yet in
@upstash/redis.upstash_redis
upstash_redis
This command is not supported yet in
upstash_redis.ioredis
ioredis
node-redis
node-redis
redis-py
redis-py
go-redis
go-redis
jedis
jedis
redis-rs
redis-rs