The Redis SMEMBERS command returns all the members of a set. If the set does not exist, it is treated as an empty set.

Syntax

The basic syntax of the SMEMBERS command is as follows:

1
SMEMBERS key

This command returns all the members of the set value stored at key. It has the same effect as running SINTER with one argument key.

Available Since

Redis version >= 1.0.0

Time Complexity

O(N) where N is the set cardinality.

ACL Categories

@read, @set, @slow

Return Value

Returns a set with all the members of the set.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
127.0.0.1:6379> SADD key1 a b c d
(integer) 4
127.0.0.1:6379> SMEMBERS key1
1) "c"
2) "b"
3) "a"
4) "d"
127.0.0.1:6379> SINTER key1
1) "c"
2) "b"
3) "a"
4) "d"
127.0.0.1:6379>