redis HINCRBYFLOAT command
Translation results:
incr
abbr.increase (value, price, inventory, amount, production, etc.) increase;increasing increase;increased increase;incremental increase
by
英[baɪ] 美[baɪ]
prep.beside...;expression method;due to;passing through
adv.passing;expressing reservation Or use when saving; short visit
float
英[fləʊt] 美[floʊt]
vt.& vi. (make) float; (make) float; float freely
vi. wander
vt. put forward, draw for consideration; (stock) go public
n. float; floating object; floating board; A drink with ice cream floating on it
Third person singular: floats Plural: floats Present participle: floating Past tense: floated Past participle: floated
redis HINCRBYFLOAT commandsyntax
Function: Add floating point increment to the field field in the hash table key.
Syntax: HINCRBYFLOAT key field increment
Description: If there is no field field in the hash table, then HINCRBYFLOAT will first add the value of the field field Set to 0 before performing the addition operation. If the key key does not exist, then HINCRBYFLOAT will first create a hash table, then create the field field, and finally perform the addition operation.
Available versions: >= 2.6.0
Time complexity: O(1)
Return: The value of the field field after performing the addition operation.
redis HINCRBYFLOAT commandexample
# 值和增量都是普通小数 redis> HSET mykey field 10.50 (integer) 1 redis> HINCRBYFLOAT mykey field 0.1 "10.6" # 值和增量都是指数符号 redis> HSET mykey field 5.0e3 (integer) 0 redis> HINCRBYFLOAT mykey field 2.0e2 "5200" # 对不存在的键执行 HINCRBYFLOAT redis> EXISTS price (integer) 0 redis> HINCRBYFLOAT price milk 3.5 "3.5" redis> HGETALL price 1) "milk" 2) "3.5" # 对不存在的域进行 HINCRBYFLOAT redis> HGETALL price 1) "milk" 2) "3.5" redis> HINCRBYFLOAT price coffee 4.5 # 新增 coffee 域 "4.5" redis> HGETALL price 1) "milk" 2) "3.5" 3) "coffee" 4) "4.5"