Each hash can store 4,294,967,295 key-value pairs
Type of hash (hash):
Hset Assignment Value
127.0.0.1:6379> hset H1 username java1234
(integer) 1
127.0.0.1:6379> hset H1 Password 123456
(integer) 1
Hget value
127.0.0.1:6379> Hget H1 username
"Java1234"
127.0.0.1:6379> hget H1 Password
"123456"
Hmset multiple fields together set
127.0.0.1:6379> hmset h2 username open1111 password 123456
Ok
127.0.0.1:6379> hget H2 username
"Open1111"
127.0.0.1:6379> hget H2 Password
"123456"
Hmget multiple fields together to get
127.0.0.1:6379> hmget H2 username password
1) "open1111"
2) "123456"
Hgetall get hash all key value pairs
127.0.0.1:6379> Hgetall H2
1) "username"
2) "open1111"
3) "Password"
4) "123456"
Hdel Delete attributes (one or more at a time)
One
127.0.0.1:6379> Hgetall H1
1) "username"
2) "java1234"
3) "Password"
4) "123456"
127.0.0.1:6379> Hdel H1 username
(integer) 1
127.0.0.1:6379> Hgetall H1
1) "Password"
2) "123456"
Multiple
127.0.0.1:6379> Hgetall H2
1) "username"
2) "open1111"
3) "Password"
4) "123456"
127.0.0.1:6379> Hdel H2 username password
(integer) 2
127.0.0.1:6379> Hgetall H2
(empty list or set)
Hincrby adding numbers
127.0.0.1:6379> Hset H1 age 20
(integer) 1
127.0.0.1:6379> Hget H1 Age
"20"
127.0.0.1:6379> Hincrby H1 age 5
(integer) 25
127.0.0.1:6379> Hget H1 Age
"25"
Hexists the existence of a field 1 indicates that there is 0 indicating that there is no
127.0.0.1:6379> hexists H1 Age
(integer) 1
127.0.0.1:6379> hexists H1 Age1
(integer) 0
Hlen Perhaps the number of hash attributes
127.0.0.1:6379> Hgetall H1
1) "Password"
2) "123456"
3) "Age"
4) "25"
127.0.0.1:6379> Hlen H1
(integer) 2
Hkeys Get all property names
127.0.0.1:6379> Hlen H1
(integer) 2
127.0.0.1:6379> Hkeys H1
1) "Password"
2) "Age"
Hvals Get all property values
127.0.0.1:6379> Hgetall H1
1) "Password"
2) "123456"
3) "Age"
4) "25"
127.0.0.1:6379> hvals H1
1) "123456"
2) "25"