# SREM

> Remove one or more members from a set.

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

```
SREM key member [member ...]
```

- Group: Set
- Complexity: O(N) where N is the number of members to remove
- HotKV Cloud: all plans
- On-Premise: no license needed

`SREM` removes each `member` from the set stored at `key`. Members that are not
in the set are ignored. When the last member is removed, the key is deleted.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Integer: the number of members that were removed | Same |
| Key does not exist | Integer `0` | Same |

`SREM` 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> SREM tags "cache" "missing"
(integer) 1
127.0.0.1:6379> SMEMBERS tags
1) "redis"
2) "db"
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[SADD](https://docs.hotkv.com/commands/sadd/index.md), [SPOP](https://docs.hotkv.com/commands/spop/index.md), [SMOVE](https://docs.hotkv.com/commands/smove/index.md)