w3resource

Redis Hash: HINCRBYFLOAT

HINCRBYFLOAT key field increment

Redis HINCRBYFLOAT command is used to increment the specified field of a hash stored at key, and representing a floating point number, by the specified increment. If the field does not exist, it is set to 0 before performing the operation. If the field contains a value of wrong type or specified increment is not parsable as floating point number, then an error has occurred.

Syntax:

HINCRBYFLOAT KEY_NAME FIELD_NAME INCR_BY_NUMBER  

Available since

2.6.0.

Return Value

String reply, the value of field after the increment.

Return Value Type

Integer

Example: Redis HINCRBYFLOAT

127.0.0.1:6379> HSET langhash lang1 10.25
(integer) 1
127.0.0.1:6379> HINCRBYFLOAT langhash lang1 0.2
"10.45"
127.0.0.1:6379> HSET langhash lang1 6.0e4
(integer) 1
127.0.0.1:6379> HINCRBYFLOAT langhash lang1 3.0e3
"63000"

Example: Redis HINCRBYFLOAT another example

127.0.0.1:6379> HINCRBYFLOAT user height 85.5
"85.5"
127.0.0.1:6379> HINCRBYFLOAT user height 14.2
"99.7"
127.0.0.1:6379> HINCRBYFLOAT user height -12.5
"87.2"
127.0.0.1:6379> HINCRBYFLOAT user height 85.5
"172.7"
127.0.0.1:6379> HINCRBYFLOAT user height -85.7
"87"

Previous: HINCRBY
Next: HKEYS



Follow us on Facebook and Twitter for latest update.