Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

SMEMBERS

Last updated
SMEMBERS key
Group
Set
Complexity
O(N) where N is the size of the set
Arity
2 (exactly, counting the command name)
Flags
read-only
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

SMEMBERS returns every member of the set stored at key. The order is not defined. For large sets, prefer SSCAN so one reply does not carry the whole set.

Case RESP2 RESP3
Set exists Array of bulk strings Set of bulk strings
Key does not exist Empty array Empty set

SMEMBERS replies with a WRONGTYPE error if key holds a value that is not a set.

127.0.0.1:6379> SADD tags "redis" "cache"
(integer) 2
127.0.0.1:6379> SMEMBERS tags
1) "redis"
2) "cache"
127.0.0.1:6379> SMEMBERS nosuchkey
(empty array)

Same as Redis 7.4 and Valkey 8.

SSCAN, SISMEMBER, SCARD, SRANDMEMBER