SUNIONSTORE
SUNIONSTORE destination key [key ...]
- Group
- Set
- Complexity
- O(N) where N is the total number of members in all given sets
- Arity
- -3 (at least 3 words, counting the command name)
- Flags
- write
- Keys
- first 1, last final argument, step 1
- HotKV Cloud
- All plans
- On-Premise
- no license needed
SUNIONSTORE computes the same union as SUNION 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
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Success | Integer: the number of members in the stored set | Same |
SUNIONSTORE 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
Section titled “Examples”127.0.0.1:6379> SADD a "x" "y"(integer) 2127.0.0.1:6379> SADD b "y" "z"(integer) 2127.0.0.1:6379> SUNIONSTORE all a b(integer) 3127.0.0.1:6379> SCARD all(integer) 3Compatibility
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.