十五、Hash常用操作
127.0.0.1:6379> hset hash1 name szk
(integer) 1
127.0.0.1:6379> hset hash1 age 23
(integer) 1
127.0.0.1:6379> hset hash1 job it
(integer) 1
127.0.0.1:6379> hgetall hash1
1) "name"
2) "szk"
3) "age"
4) "23"
5) "job"
6) "it"
127.0.0.1:6379> hmset hash2 name yc age 24 job teacher #批量创建
OK
127.0.0.1:6379> hgetall hash2
1) "name"
2) "yc"
3) "age"
4) "24"
5) "job"
6) "teacher"
127.0.0.1:6379> hdel hash2 job #删除某个值
(integer) 1
127.0.0.1:6379> hgetall hash2
1) "name"
2) "yc"
3) "age"
4) "24"
127.0.0.1:6379> hkeys hash2 #查看所有的key
1) "name"
2) "age"
127.0.0.1:6379> hvals hash2 #查看所有的values
1) "yc"
2) "24"
127.0.0.1:6379> hlen hash2 #查看hash有几个filed(键值)
(integer) 2
时间: 2024-10-25 09:46:19