SADD
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.
Return value
Section titled “Return value”| 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.
Examples
Section titled “Examples”127.0.0.1:6379> SADD tags "redis" "cache" "db"(integer) 3127.0.0.1:6379> SADD tags "cache" "kv"(integer) 1127.0.0.1:6379> SCARD tags(integer) 4Compatibility
Section titled “Compatibility”Same as Redis 7.4 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.