Returns the number of members in a set.
SCARD
key
Returns the set cardinality (number of elements) of the set stored at
key
.
Integer reply: the
cardinality (number of elements) of the set, or 0
if the
key does not exist.
Integer reply: The cardinality (number of elements) of the set, or 0 if the key does not exist.
O(1)
@fast @read @set
127.0.0.1:6379> SADD myset "Hello"
(integer) 1
127.0.0.1:6379> SADD myset "World"
(integer) 1
127.0.0.1:6379> SCARD myset
(integer) 2
SADD, SDIFF, SDIFFSTORE, SINTER, SINTERCARD, SINTERSTORE, SISMEMBER, SMEMBERS, SMISMEMBER, SMOVE, SPOP, SRANDMEMBER, SREM, SSCAN, SUNION, SUNIONSTORE.