Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

HINCRBY

Last updated
HINCRBY key field increment
Group
Hash
Complexity
O(1)
Arity
4 (exactly, counting the command name)
Flags
write, fast
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

HINCRBY adds increment to the integer stored in field of the hash at key and returns the new value. A missing key or field starts at 0. Use a negative increment to subtract. The field keeps any time to live it already had.

The increment and the stored value must both be signed 64-bit integers written in plain decimal form.

Case RESP2 RESP3
Success Integer: the value after the increment Same

Errors:

  • ERR value is not an integer or out of range if increment is not an integer.
  • WRONGTYPE if key holds a value that is not a hash.
  • ERR hash value is not an integer if the field holds something that is not an integer.
  • ERR increment or decrement would overflow if the result does not fit in a signed 64-bit integer.
127.0.0.1:6379> HSET stats:page views 10
(integer) 1
127.0.0.1:6379> HINCRBY stats:page views 5
(integer) 15
127.0.0.1:6379> HINCRBY stats:page views -20
(integer) -5
127.0.0.1:6379> HINCRBY stats:page clicks 1
(integer) 1

Same as Redis 7.4 and Valkey 8.

HINCRBYFLOAT, HSET, HGET, INCRBY