# SADD

> Add one or more members to a set.

URL: https://docs.hotkv.com/commands/sadd/

```
SADD key member [member ...]
```

- Group: Set
- Complexity: O(1) for each member added
- 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

| 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

```
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
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[SREM](https://docs.hotkv.com/commands/srem/index.md), [SMEMBERS](https://docs.hotkv.com/commands/smembers/index.md), [SISMEMBER](https://docs.hotkv.com/commands/sismember/index.md),
[SCARD](https://docs.hotkv.com/commands/scard/index.md)