Redis SMEMBERS – How to get all elements of a set in redis

6 days ago Lalit Bhagtani 0

In this tutorial, we will learn about how to get all the elements of a set value stored at the key, by using a COMMAND – SMEMBERS in redis-cli. The syntax of redis SMEMBERS command is as follows :-

Syntax :-

redis host:post> SMEMBERS <key name>

Output :- 

- array value, containing all elements of the set.
- error, if key exist and value stored at the key is not a set.

Example :-

Redis SMEMBERS

References :-

  1. SMEMBERS Command Docs

That’s all for how to get all the elements of a set value in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.