HINCRBYFLOAT
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.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Success | Bulk string: the value after the increment | Bulk string |
Errors:
ERR value is not a valid floatifincrementis not a number.WRONGTYPEifkeyholds a value that is not a hash.ERR hash value is not a valid floatif the field holds something that is not a number, or if the result would be infinite or not a number.
Examples
Section titled “Examples”127.0.0.1:6379> HSET item:7 price 10.5(integer) 1127.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"Compatibility
Section titled “Compatibility”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).
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.