HINCRBY

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

将存储在key中的哈希表中field处的数字增加increment。 如果key不存在,则创建一个包含哈希表的新键。 如果field不存在,则在执行操作之前将其值设置为0

HINCRBY 支持的值范围仅限于64位有符号整数。

示例

由于increment参数是有符号的,因此可以执行增量和减量操作:

HSET myhash field 5 HINCRBY myhash field 1 HINCRBY myhash field -1 HINCRBY myhash field -10

RESP2/RESP3 回复

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