HINCRBYFLOAT

Syntax
HINCRBYFLOAT key field increment
Available since:
2.6.0
Time complexity:
O(1)
ACL categories:
@write, @hash, @fast,

增加存储在key处的哈希中指定的field,该字段表示一个浮点数,增加指定的increment。如果增量值为负,结果是哈希字段值减少而不是增加。如果字段不存在,则在执行操作之前将其设置为0。如果发生以下任一情况,将返回错误:

  • 键包含错误类型的值(不是哈希)。
  • 当前字段内容或指定的增量无法解析为双精度浮点数。

此命令的确切行为与INCRBYFLOAT命令完全相同,请参阅INCRBYFLOAT的文档以获取更多信息。

示例

HSET mykey field 10.50 HINCRBYFLOAT mykey field 0.1 HINCRBYFLOAT mykey field -5 HSET mykey field 5.0e3 HINCRBYFLOAT mykey field 2.0e2

实现细节

该命令始终在复制链路和仅追加文件中作为HSET操作传播,因此底层浮点数学实现的差异不会成为不一致的来源。

RESP2 回复

Bulk string reply: the value of the field after the increment operation.

RESP3 回复

Bulk string reply: The value of the field after the increment operation.
RATE THIS PAGE
Back to top ↑