Back to Redis

SREM

content/commands/srem.md

latest1.3 KB
Original Source

Remove the specified members from the set stored at key. Specified members that are not a member of this set are ignored. If key does not exist, it is treated as an empty set and this command returns 0.

An error is returned when the value stored at key is not a set.

Examples

{{% redis-cli %}} SADD myset "one" SADD myset "two" SADD myset "three" SREM myset "one" SREM myset "four" SMEMBERS myset {{% /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="srem-return-info" tab1="RESP2" tab2="RESP3" >}}

Integer reply: the number of members that were removed from the set, not including non existing members.

-tab-sep-

Integer reply: Number of members that were removed from the set, not including non existing members.

{{< /multitabs >}}