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.

HINCRBYFLOAT

Last updated
HINCRBYFLOAT 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

HINCRBYFLOAT adds increment to the number 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 can be written as a decimal (1.5), with an exponent (2e3), or as an integer. The result is stored as a decimal string without trailing zeros.

Case RESP2 RESP3
Success Bulk string: the value after the increment Bulk string

Errors:

  • ERR value is not a valid float if increment is not a number.
  • WRONGTYPE if key holds a value that is not a hash.
  • ERR hash value is not a valid float if the field holds something that is not a number, or if the result would be infinite or not a number.
127.0.0.1:6379> HSET item:7 price 10.5
(integer) 1
127.0.0.1:6379> HINCRBYFLOAT item:7 price 0.25
"10.75"
127.0.0.1:6379> HINCRBYFLOAT item:7 price -0.75
"10"
127.0.0.1:6379> HINCRBYFLOAT item:7 weight 2e3
"2000"

Same arguments and successful replies as Redis 7.4 and Valkey 8. The error text differs: where Redis and Valkey reply ERR hash value is not a float, HotKV replies ERR hash value is not a valid float, and HotKV uses that same error when the increment or the result would be infinite (Redis and Valkey reply ERR value is NaN or Infinity or ERR increment would produce NaN or Infinity).

HINCRBY, HSET, HGET, INCRBYFLOAT