hash数据类型的相关命令
1,hset命令
127.0.0.1:6379> hset user name yuhao
(integer) 1
127.0.0.1:6379> hset user age 19
(integer) 1
127.0.0.1:6379> hset user from qinghai
(integer) 1
127.0.0.1:6379> hgetall user
1) "name"
2) "yuhao"
3) "age"
4) "19"
5) "from"
6) "qinghai"
2,hmset设定多项值
127.0.0.1:6379> hmset user1 name gss age 19
OK
查看某列值
127.0.0.1:6379> hget user1 name
"gss"
查看所有
127.0.0.1:6379> hgetall user1
1) "name"
2) "gss"
3) "age"
4) "19"
3,删除一个值
127.0.0.1:6379> hdel user1 age
(integer) 1
127.0.0.1:6379> hget user1 age
(nil)
4,统计
127.0.0.1:6379> hlen user
(integer) 3
127.0.0.1:6379> hlen user1
(integer) 1
5,判断key中的值是否存在
127.0.0.1:6379> hexists user name
(integer) 1
127.0.0.1:6379> hexists user1 age
(integer) 0
6,查看全部hash
127.0.0.1:6379> hkeys user
1) "name"
2) "age"
3) "from"
127.0.0.1:6379> hkeys user1
1) "name"
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。