1.赋值与取值命令
127.0.0.1:6379> hset stu name qiao
(integer) 1
127.0.0.1:6379> hset stu sex man
(integer) 1
127.0.0.1:6379> hget stu name
"qiao"
127.0.0.1:6379> HMSET st name sun age 22
OK
127.0.0.1:6379> HMGET st name age
1) "sun"
2) "22"
127.0.0.1:6379> HGETALL st
1) "name"
2) "sun"
3) "age"
4) "22"
2.判断字段是否存在,字段不存在赋值
127.0.0.1:6379> HEXISTS stu name
(integer) 1
127.0.0.1:6379> HEXISTS stu age
(integer) 0
127.0.0.1:6379> HSETNX stu age 33
(integer) 1
127.0.0.1:6379> HGET stu age
"33"
3.增加指定的整数
127.0.0.1:6379> HINCRBY stu age 22
(integer) 55
127.0.0.1:6379> HGET stu age
"55"
4.删除字段
127.0.0.1:6379> HDEL st name age
(integer) 2
5.只获取字段名或者字段值
127.0.0.1:6379> HKEYS stu
1) "name"
2) "sex"
3) "age"
127.0.0.1:6379> HVALS stu
1) "qiao"
2) "man"
3) "55"
6.获取字段数量
127.0.0.1:6379> HLEN stu
(integer) 3