Redis INCRBYFLOAT – How to increment a floating point value in redis

2 months ago Lalit Bhagtani 0

In this tutorial, we will learn about how to increment the string representing a floating point value stored at a key in redis datastore. For this, we will use a Redis INCRBYFLOAT command. 

INCRBYFLOAT Command

This command is used to increment the string representing a floating point number stored at the key by the specified value. If the key does not exist, it is first created and set to 0 before performing the increment operation. If the key exists but value stored at the key is of the wrong datatype ( not string datatype ) or contains a string value that can not be represented as a double precision floating point number then an error is returned. The syntax of Redis INCRBYFLOAT command is as follows:-

Syntax :-

redis host:post> INCRBYFLOAT <keyname> <increment>

Output :-

- (string) reply, representing the value of the key after the increment operation.

Example :-

Redis INCRBYFLOAT

References :-

  1. INCRBYFLOAT Command Docs

That’s all for how to increment the string representing a floating point value stored in redis datastore. If you liked it, please share your thoughts in comments section and share it with others too.

<- String Commands