English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Incrbyfloat command

Redis Strings (string)

The Redis Incrbyfloat command adds the specified floating-point increment value to the value stored in the key.

If the key does not exist, INCRBYFLOAT will first set the value of the key to 0, and then perform the addition operation.

Syntax

The basic syntax of the redis Incrbyfloat command is as follows:

redis 127.0.0.1:6379> INCRBYFLOAT KEY_NAME INCR_AMOUNT

Available Versions

>= 2.6.0

Return Value

The value of the key after executing the command.

Online Examples

# Neither the value nor the increment is in exponential notation
redis> SET mykey 10.50
OK
redis> INCRBYFLOAT mykey 0.1
"10.6"
# Both the value and the increment are in exponential notation
redis> SET mykey 314e-2
OK
redis> GET mykey                # The value set by SET can be in exponential notation
"314e-2"
redis> INCRBYFLOAT mykey 0      # But the format will be changed to non-exponential notation after executing INCRBYFLOAT
"3.14"
# You can perform operations on integer types
redis> SET mykey 3
OK
redis> INCRBYFLOAT mykey 1.1
"4.1"
# The 0 that follows will be removed
redis> SET mykey 3.0
OK
redis> GET mykey                                    # The decimal part of the value set by SET can be 0
"3.0"
redis> INCRBYFLOAT mykey 1.000000000000000000000    # But INCRBYFLOAT will ignore the useless 0,and if necessary,convert the float to an integer
"4"
redis> GET mykey
"4"

Redis Strings (string)