Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

SCARD

Last updated
SCARD key
Group
Set
Complexity
O(1)
Arity
2 (exactly, counting the command name)
Flags
read-only, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

SCARD returns the number of members (the cardinality) of the set stored at key.

Case RESP2 RESP3
Set exists Integer: the number of members Same
Key does not exist Integer 0 Same

SCARD replies with a WRONGTYPE error if key holds a value that is not a set.

127.0.0.1:6379> SADD tags "redis" "cache" "db"
(integer) 3
127.0.0.1:6379> SCARD tags
(integer) 3
127.0.0.1:6379> SCARD nosuchkey
(integer) 0

Same as Redis 7.4 and Valkey 8.

SMEMBERS, SINTERCARD, SADD