Redis Incrbyfloat Command
--
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
Redis Tutorial
Redis Tutorial
Redis Introduction
Redis Installation
Redis Configuration
Redis Data Types
Redis Commands
Redis Commands
Redis Keys
Redis Strings
Redis Hashes
Redis Lists
Redis Sets
Redis Sorted Sets
Redis HyperLogLog
Redis Pub/Sub
Redis Transactions
Redis Scripting
Redis Connection
Redis Server
Redis GEO
Redis Stream
Advanced Redis Tutorial
Redis Backup and Recovery
Redis Security
Redis Performance Testing
Redis Client Connection
Redis Pipelining
Redis Partitioning
Java Using Redis
PHP Using Redis
Redis Keys
Redis Hashes
Redis Incrbyfloat Command
Redis Strings
The Redis Incrbyfloat command increments the value of key by the specified floating point number increment.
If key does not exist, it is set to 0 before performing the operation.
Syntax
The basic syntax of 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 key after the command is executed.
Example
# Neither value nor increment are in scientific notation
redis> SET mykey 10.50
OK
redis> INCRBYFLOAT mykey 0.1
"10.6"
# Both value and increment are in scientific notation
redis> SET mykey 314e-2
OK
redis> GET mykey
# The value set by SET can be in scientific notation
"314e-2"
redis> INCRBYFLOAT mykey 0
# But after executing INCRBYFLOAT, the format will be changed to non-scientific notation
"3.14"
# Can be performed on integer types
redis> SET mykey 3
OK
redis> INCRBYFLOAT mykey 1.1
"4.1"
# Trailing 0s are 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 unnecessary 0s, converting floats to integers if necessary
"4"
redis> GET mykey
"4"
YouTip