w3resource

Redis Sets: SMEMBERS

Redis SMEMBERS Command

Redis SMEMBERS command is used to return all the members of the set value stored at key.

Here are some common uses and scenarios for the "SMEMBERS" command:

  • Data Analysis: Analyze the contents of a set for reporting or auditing purposes.
  • Set Inspection: Inspect and verify the elements stored in a set.
  • Data Export: Export the elements of a set for backup, migration, or integration with other systems.
  • Application Logic: Use the retrieved set members to drive application logic, such as generating dynamic lists or menus.

Syntax:

SMEMBERS KEY 

Available since:

1.0.0.

Return Value:

Array reply : all elements of the set.

Return Value Type:

Array

Example: Redis SMEMBERS

127.0.0.1:6379> SADD mycolor1 "red" "green" "blue"
(integer) 3
127.0.0.1:6379> SADD mycolor1 "orange" "yellow"
(integer) 2
127.0.0.1:6379> SMEMBERS  mycolor1
1) "blue"
2) "orange"
3) "green"
4) "red"
5) "yellow"

Previous: Redis Sets SISMEMBERS
Next: Redis Sets SMOVE



Follow us on Facebook and Twitter for latest update.