HINCRBYFLOAT

Syntax

  1. HINCRBYFLOAT key field increment

Time complexity: O(1)

Increment the specified field of a hash stored at key, and representing a floating point number, by the specified increment. If the increment value is negative, the result is to have the hash field value decremented instead of incremented. If the field does not exist, it is set to 0 before performing the operation. An error is returned if one of the following conditions occur:

  • The field contains a value of the wrong type (not a string).
  • The current field content or the specified increment are not parsable as a double precision floating point number.

The exact behavior of this command is identical to the one of the INCRBYFLOAT command, please refer to the documentation of INCRBYFLOAT for further information.

Return

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

Examples

  1. dragonfly> HSET mykey field 10.50
  2. (integer) 1
  3. dragonfly> HINCRBYFLOAT mykey field 0.1
  4. "10.6"
  5. dragonfly> HINCRBYFLOAT mykey field -5
  6. "5.6"
  7. dragonfly> HSET mykey field 5.0e3
  8. (integer) 0
  9. dragonfly> HINCRBYFLOAT mykey field 2.0e2
  10. "5200"

Implementation details

The command is always propagated in the replication link and the Append Only File as a HSET operation, so that differences in the underlying floating point math implementation will not be sources of inconsistency.