incrbyfloat
INCRBYFLOAT
Increment by a given number (integer/float)
Increments by the specified number.
If the key does not exist, 0 is used as the base and the specified number is returned.
Example
| Command> | incrbyfloat key 15.6
|
| Result> | 15.6
|
| Command> | incrbyfloat key 3.3
|
| Result> | 18.9
|
|
In AOF it is rewritten and recorded as a SET command.
From version 6.0, the KEEPTTL option was added to SET to preserve expire time. SET key 18.9 KEEPTTL
|
Negative numbers are allowed
You can also specify a negative number.
Example
| Command> | incrbyfloat key -25.5
|
| Result> | -25.5
|
Syntax
INCRBYFLOAT key increment
- Available since version 2.6.0.
- Time complexity is O(1).