Use INCRBYFLOAT to add a floating point number to the value stored at a key and get the result.
The stored value and the increment are parsed as double precision floats, and a missing key counts as 0. A negative increment subtracts, and there is no separate decrement command. A value that is not a valid number returns an error.
The reply is the new value as a string, which client libraries usually decode into a native number. The result is stored in that same textual form, so repeated increments accumulate the usual binary floating point rounding error: for money and other exact quantities, count in integer units with INCRBY instead.
Syntax#
Arguments#
| Argument | Required | Repeatable | Description |
|---|---|---|---|
<key> | Yes | No | Redis key targeted by the command. |
<increment> | Yes | No | Amount to add to the value; may be a floating-point number. |
Important points#
- The value is always returned as a bulk string, in both RESP2 and RESP3. Client libraries commonly decode it to a language number.
Response#
The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
| Protocol | Reply |
|---|---|
| RESP2 | Bulk string |
| RESP3 | Bulk string |
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
Examples#
TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.