w3resource

Redis String: INCRBYFLOAT

Redis INCRBYFLOAT Command

Redis INCRBYFLOAT command is used to increments the string representing a floating point number stored at key by the specified increment. If the key does not exist, it is set to 0 before performing the operation. If the key contains a value of the wrong type or current key content or the specified increment are not parsable as floating point number, then an error is returned.

Here are some common uses and scenarios for the "INCRBYFLOAT" command:

  • Incremental Operations: Adjust values by floating-point increments (e.g., for metrics or financial calculations).
  • Accumulate Scores: Aggregate scores or ratings with precision.
  • Batch Processing: Increase values of multiple keys by specified float amounts efficiently.
  • Atomic Operations: Ensure atomicity when incrementing values in a multi-client environment.
  • Data Transformation: Convert or adjust floating-point values dynamically.

Syntax:

INCRBYFLOAT KEY_NAME INCR_AMOUNT

Available since

2.6.0.

Return Value

String reply, the value of key after the increment.

Return Value Type

String

Example: Redis INCRBYFLOAT

redis 127.0.0.1:6379> SET visitors 1000.20
OK
redis 127.0.0.1:6379> INCRBYFLOAT visitors .50
1000.70
redis 127.0.0.1:6379> GET visitors
1000.70

Previous: INCRBY
Next: DECR



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/redis/redis-incrbyfloat-key-increment.php