hincrbyfloat.3valkey - Man Page

Increments the floating point value of a field by a number. Uses 0 as initial value if the field doesn’t exist.

Synopsis

HINCRBYFLOAT key field increment

Description

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 exact behavior of this command is identical to the one of the INCRBYFLOAT command, please refer to the documentation of INCRBYFLOAT for further information.

Reply

Resp2

valkey-protocol(7) Bulk string reply: the value of the field after the increment operation.

Resp3

valkey-protocol(7) Bulk string reply: The value of the field after the increment operation.

Complexity

O(1)

Acl Categories

@fast @hash @write

History

Examples

127.0.0.1:6379> HSET mykey field 10.50
(integer) 1
127.0.0.1:6379> HINCRBYFLOAT mykey field 0.1
"10.6"
127.0.0.1:6379> HINCRBYFLOAT mykey field -5
"5.6"
127.0.0.1:6379> HSET mykey field 5.0e3
(integer) 0
127.0.0.1:6379> HINCRBYFLOAT mykey field 2.0e2
"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.

See Also

hdel(3valkey), hexists(3valkey), hget(3valkey), hgetall(3valkey), hincrby(3valkey), hkeys(3valkey), hlen(3valkey), hmget(3valkey), hrandfield(3valkey), hscan(3valkey), hset(3valkey), hsetnx(3valkey), hstrlen(3valkey), hvals(3valkey)

Info

2024-09-23 8.0.0 Valkey Command Manual