Created
May 21, 2017 18:43
-
-
Save indyarocks/5db6f86a7111b81e27897a440d68c61f to your computer and use it in GitHub Desktop.
Redis SET Data type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127.0.0.1:6379> SADD set-key item # Initializes a SET with key set-key. adds item and returns 1 as success | |
(integer) 1 | |
127.0.0.1:6379> SADD set-key item # item already exists, thus returns 0 as failure | |
(integer) 0 | |
127.0.0.1:6379> SADD set-key item1 # add item1 to the set with key set-key | |
(integer) 1 | |
127.0.0.1:6379> SADD set-key item2 # add item2 to the set with key set-key | |
(integer) 1 | |
127.0.0.1:6379> SMEMBERS set-key # Fetches all items in the set with key set-key | |
1) "item1" | |
2) "item2" | |
3) "item" | |
127.0.0.1:6379> SISMEMBER set-key item # Checks if item is available in the set with key set-key. Returns 1 as success | |
(integer) 1 | |
127.0.0.1:6379> SISMEMBER set-key item100 # Checks if item100 is available in the set with key set-key. Returns 0 as failure | |
(integer) 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment