The following are the main commands listed with their usages:
- SADD: It adds the element in a requested key. Also, the return of this command is the number of the element added to the set:
SADD "unique-visitors" "joe" SADD "unique-visitors" "mary"
As we can see, the command returned one because we added one user each time.
- SMEMBERS: It returns all the members of a requested key:
SMEMBERS "unique-visitors"
The command will return joe and mary because those are the values stored in the unique-visitors key.
- SCARD: It returns the numbers of elements of a requested key:
SCARD "unique-visitors"
The command will return the number of elements stored in the requested keys, in this case, the output will be 2.