SMEMBERS
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.
Return value
Section titled “Return value”| 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.
Examples
Section titled “Examples”127.0.0.1:6379> SADD tags "redis" "cache"(integer) 2127.0.0.1:6379> SMEMBERS tags1) "redis"2) "cache"127.0.0.1:6379> SMEMBERS nosuchkey(empty array)Compatibility
Section titled “Compatibility”Same as Redis 7.4 and Valkey 8.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.