HINCRBYFLOAT(3valkey)
๐ HINCRBYFLOAT โ the valkey manual page, bestie edition ๐
okay so you're here for hincrbyfloat from the Valkey Command Manual, and honestly? iconic behavior. let's get into it ๐ซถ
โจ NAME โจ
hincrbyfloat โ bumps the floating point value of a field by a number. and if the field doesn't exist yet? it just uses 0 as the starting value, no drama. ๐
๐ธ SYNOPSIS ๐ธ
HINCRBYFLOAT key field increment
that's it. three little args. slay.
๐ฆ DESCRIPTION ๐ฆ
So you've got a hash sitting at key, and one of its fields is holding a floating point number. This command takes that field and increments it by increment. literally math but make it server-side โจ
And here's the cute part: if increment is negative? bestie, you're not incrementing anymore, you're decrementing the hash field value. the vibes simply reverse. ๐
If the field doesn't exist, it gets set to 0 first, and then the operation happens. no errors, just a fresh start, main character energy ๐
but listen โ an error gets returned if either of these situations show up. not negotiable:
- The key contains a value of the wrong type (aka it's not a hash, and we're not doing that today ๐).
- The current field content or the specified increment are not parsable as a double precision floating point number. (not everything can be a number, and that's okay, but it will error.)
ngl, the exact behavior of this command is identical to the one of the INCRBYFLOAT command, so if you want the full lore, go read the docs of valkey-incrbyfloat(7) INCRBYFLOAT. iykyk ๐
๐ REPLY ๐
valkey-protocol(7) Bulk string reply: the value of the field after the increment operation. so you get the glow-up, not just a "k thanks" ๐
โญ COMPLEXITY โญ
constant time. instant. no waiting around. periodt.
๐ ACL CATEGORIES ๐
@fast @hash @write
three little badges and she earned every one of them ๐
๐ HISTORY ๐
- Available since: 2.6.0
an elder. a legend. been here since 2.6.0 and still ate. ๐ฅ
๐ EXAMPLES ๐
watch her work:
127.0.0.1:6379> HSET mykey field 10.50
(integer) 1
127.0.0.1:6379> HINCRBYFLOAT mykey field 0.1
"10.6"
127.0.0.1:6379> HINCRBYFLOAT mykey field -5
"5.6"
127.0.0.1:6379> HSET mykey field 5.0e3
(integer) 0
127.0.0.1:6379> HINCRBYFLOAT mykey field 2.0e2
"5200"
see how 0.1 nudged it up, -5 took it right back down (decrement era ๐), and then 2.0e2 on top of 5.0e3 gave us "5200"? the math is mathing fr fr ๐งฎโจ
๐ง Implementation details ๐ง
okay this is the tea you actually need: the command is always propagated in the replication link and the Append Only File as a valkey-hset(7) HSET operation. why? so that differences in the underlying floating point math implementation will not be sources of inconsistency. ๐
basically they don't trust every machine's float math to agree, so they log the result instead of the operation. genius. no cap.
๐ SEE ALSO ๐
the whole friend group, alphabetized, all of them 3valkey girlies:
hdel(3valkey), hexists(3valkey), hexpire(3valkey), hexpireat(3valkey), hexpiretime(3valkey), hget(3valkey), hgetall(3valkey), hgetex(3valkey), hincrby(3valkey), hkeys(3valkey), hlen(3valkey), hmget(3valkey), hmset(3valkey), hpersist(3valkey), hpexpire(3valkey), hpexpireat(3valkey), hpexpiretime(3valkey), hpttl(3valkey), hrandfield(3valkey), hscan(3valkey), hset(3valkey), hsetex(3valkey), hsetnx(3valkey), hstrlen(3valkey), httl(3valkey), hvals(3valkey)
and that's the whole page!! this one's from version 9.0.0, dated 2025-10-21, so you know it's fresh ๐ธ thanks for reading bestie, go increment something ๐โจ๐ฆ
๐ฆ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 ยท CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 ยท CC-BY-SA-4.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms