# SINTERSTORE

> Store the intersection of sets in a destination key.

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

```
SINTERSTORE destination key [key ...]
```

- Group: Set
- Complexity: O(N*M) worst case, where N is the size of the smallest set and M is the number of sets
- HotKV Cloud: all plans
- On-Premise: no license needed

`SINTERSTORE` computes the same intersection as [SINTER](https://docs.hotkv.com/commands/sinter/index.md) and
stores it as a set at `destination`, replacing whatever `destination` held
before (of any type, and without its time to live). If the result is empty,
`destination` is deleted. The source sets are read and the result written as
one atomic step, and `destination` can also be one of the source keys.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Integer: the number of members in the stored set | Same |

`SINTERSTORE` replies with a `WRONGTYPE` error if any source key holds a value
that is not a set. `destination` is not changed in that case.

## Examples

```
127.0.0.1:6379> SADD a "x" "y" "z"
(integer) 3
127.0.0.1:6379> SADD b "y" "z" "w"
(integer) 3
127.0.0.1:6379> SINTERSTORE common a b
(integer) 2
127.0.0.1:6379> SMEMBERS common
1) "y"
2) "z"
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[SINTER](https://docs.hotkv.com/commands/sinter/index.md), [SUNIONSTORE](https://docs.hotkv.com/commands/sunionstore/index.md), [SDIFFSTORE](https://docs.hotkv.com/commands/sdiffstore/index.md),
[ZINTERSTORE](https://docs.hotkv.com/commands/zinterstore/index.md)