Back to Redis

SMEMBERS

content/commands/smembers.md

latest1.5 KB
Original Source

Returns all the members of the set value stored at key.

This has the same effect as running [SINTER]({{< relref "/commands/sinter" >}}) with one argument key.

Examples

{{< clients-example set="cmds_set" step="smembers" description="Foundational: Retrieve all members of a set using SMEMBERS (returns unordered collection, useful for iterating all set members)" difficulty="beginner" >}} redis> SADD myset "Hello" (integer) 1 redis> SADD myset "World" (integer) 1 redis> SMEMBERS myset

  1. "Hello"
  2. "World" {{< /clients-example >}}

Give these commands a try in the interactive console:

{{% redis-cli %}} SADD myset "Hello" SADD myset "World" 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="smembers-return-info" tab1="RESP2" tab2="RESP3" >}}

Array reply: an array with all the members of the set.

-tab-sep-

Set reply: a set with all the members of the set.

{{< /multitabs >}}