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.

SADD

Last updated
SADD key member [member ...]
Group
Set
Complexity
O(1) for each member added
Arity
-3 (at least 3 words, counting the command name)
Flags
write, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

SADD adds each member to the set stored at key, creating the set if the key does not exist. Members that are already in the set are ignored.

Case RESP2 RESP3
Success Integer: the number of members that were newly added Same

SADD 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> SADD tags "cache" "kv"
(integer) 1
127.0.0.1:6379> SCARD tags
(integer) 4

Same as Redis 7.4 and Valkey 8.

SREM, SMEMBERS, SISMEMBER, SCARD