Created
May 21, 2017 19:05
-
-
Save indyarocks/bbda097b210dbdf8f561000210f0c807 to your computer and use it in GitHub Desktop.
Redis HASH 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> HSET my_hash key1 1 # Initializes a HASH my_hash with key-value key1: 1 | |
(integer) 1 | |
127.0.0.1:6379> HSET my_hash key2 value2 # Sets another key-value pair key2: value2 in my_hash | |
(integer) 1 | |
127.0.0.1:6379> HGET my_hash key1 # GET the data for key1 in my_hash | |
"1" | |
127.0.0.1:6379> HGET my_hash key2 # GET the data for key2 in my_hash | |
"value2" | |
127.0.0.1:6379> HGETALL my_hash # GET the complete data in my_hash | |
1) "key1" | |
2) "1" | |
3) "key2" | |
4) "value2" | |
127.0.0.1:6379> HDEL my_hash unknown_key # DELETE the data for non-existing key unknown_key in my_hash. Returns 0 as failure | |
(integer) 0 | |
127.0.0.1:6379> HDEL my_hash key1 # DELETE the data for an existing key key1 in my_hash. Returns 1 as success | |
(integer) 1 | |
127.0.0.1:6379> HGETALL my_hash # GETALL the data in my_hash. | |
1) "key2" | |
2) "value2" | |
127.0.0.1:6379> HDEL my_hash key1 # Try to DELETE the data for an already deleted key key1 in my_hash. Returns 0 as failure | |
(integer) 0 | |
127.0.0.1:6379> HGET my_hash key1 # GET the data for key1 in my_hash. Returns 0 as failure | |
(nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment