content/commands/sadd.md
Add the specified members to the set stored at key.
Specified members that are already a member of this set are ignored.
If key does not exist, a new set is created before adding the specified
members.
An error is returned when the value stored at key is not a set.
{{< clients-example set="cmds_set" step="sadd" description="Foundational: Add one or more members to a set using SADD (creates set if needed, ignores duplicates, returns count of new members)" difficulty="beginner" >}} redis> SADD myset "Hello" "World" (integer) 2 redis> SADD myset "World" (integer) 0 redis> SMEMBERS myset
Give these commands a try in the interactive console:
{{% redis-cli %}} SADD myset "Hello" "World" SADD myset "World" SMEMBERS myset {{% /redis-cli %}}
| 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> | |
{{< multitabs id="sadd-return-info" tab1="RESP2" tab2="RESP3" >}}
Integer reply: the number of elements that were added to the set, not including all the elements already present in the set.
-tab-sep-
Integer reply: the number of elements that were added to the set, not including all the elements already present in the set.
{{< /multitabs >}}