Back to Redis

SUNIONSTORE

content/commands/sunionstore.md

latest1.4 KB
Original Source

{{< note >}} This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. {{< /note >}}

This command is equal to [SUNION]({{< relref "/commands/sunion" >}}), but instead of returning the resulting set, it is stored in destination.

If destination already exists, it is overwritten.

Examples

{{% redis-cli %}} SADD key1 "a" SADD key1 "b" SADD key1 "c" SADD key2 "c" SADD key2 "d" SADD key2 "e" SUNIONSTORE key key1 key2 SMEMBERS key {{% /redis-cli %}}

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |

Return information

{{< multitabs id="sunionstore-return-info" tab1="RESP2" tab2="RESP3" >}}

Integer reply: the number of elements in the resulting set.

-tab-sep-

Integer reply: Number of the elements in the resulting set.

{{< /multitabs >}}