learn-tech/专栏/Redis核心原理与实战/09附录:更多字典操作命令.md
2024-10-16 06:37:41 +08:00

90 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

因收到Google相关通知网站将会择期关闭。相关通知内容
09 附录:更多字典操作命令
插入一个或多个元素
语法hmset key field value [field value …] 示例:
127.0.0.1:6379> hmset myhash k1 val1 k2 val2
OK
127.0.0.1:6379> hmget myhash k1 k2
1) "val1"
2) "val2"
查询一个或多个元素
语法hmget key field [field …] 示例:
127.0.0.1:6379> hmget myhash k1 k2
1) "v1"
2) "v2"
查询某个 key 的所有字段
语法hkeys key 示例:
127.0.0.1:6379> hkeys myhash
1) "key1"
2) "key2"
查询某个 key 的所有值
语法hvals key 示例:
127.0.0.1:6379> hvals myhash
1) "value1"
2) "value2"
查询某个 key 的所有字段和值
语法hgetall key 示例:
127.0.0.1:6379> hgetall myhash
1) "k1"
2) "v1"
3) "k2"
4) "v2"
某个浮点值累加计算
语法hincrbyfloat key field increment 示例:
127.0.0.1:6379> hincrbyfloat myhash k3 2.2
"9.2"
查询元素是否存在
语法hexists key field 示例:
127.0.0.1:6379> hexists myhash key1
(integer) 1
查询元素个数
语法hlen key 示例:
127.0.0.1:6379> hlen myhash
(integer) 2