INCRBY(3valkey)
๐ INCRBY โ the "add a number to my key" command (from the valkey(3valkey) manual) ๐
okay bestie, listen. this is incrby from the Valkey Command Manual and it is literally the glow-up command. it bumps the integer value of a key by a number, and if the key doesn't exist yet it just starts from 0 like a fresh little baby. iconic behaviour honestly. โจ
๐ธ SYNOPSIS ๐ธ
INCRBY key increment
that's it. that's the whole vibe. two args and you're done. ๐ซถ
๐ DESCRIPTION ๐
so here's the tea: INCRBY increments the number stored at key by increment. ๐
if the key does not exist, it gets set to 0 first and then the operation happens. so yes, your first INCRBY on a brand-new key is basically a SET, but make it math. ๐งฎโจ
โ ๏ธ bestie. pay attention. an error gets returned if the key holds a value of the wrong type, or if it holds a string that can not be represented as integer. so don't go throwing "hello kitty" in there and expecting arithmetic. she will not do it. ๐
also, this operation is limited to 64 bit signed integers. that's the ceiling, that's the floor, that's the whole apartment. don't come crying when you overflow it. ๐
oh and ps โ go read INCR if you want the extra information on increment/decrement operations. the girlies who know, know. ๐
๐ REPLY ๐
valkey-protocol(7) Integer reply: the value of the key after the increment. so you get the glow-up result, not the old dusty number. โญ
๐ COMPLEXITY ๐
constant time. no notes. she's fast, she's efficient, she's serving. ๐ฅ
โจ ACL CATEGORIES โจ
@fast@string@write
three little badges, all of them slaying. ๐
๐ฆ HISTORY ๐ฆ
- Available since:
1.0.0
a literal elder. been here since the beginning and still eating. ๐
๐ EXAMPLES ๐
watch her work:
127.0.0.1:6379> SET mykey "10"
OK
127.0.0.1:6379> INCRBY mykey 5
(integer) 15
10 + 5 = 15. math is mathing. the key said "not me levelling up in public". ๐ญ๐
๐ SEE ALSO ๐
append(3valkey)decr(3valkey)decrby(3valkey)delifeq(3valkey)get(3valkey)getdel(3valkey)getex(3valkey)getrange(3valkey)getset(3valkey)incr(3valkey)incrbyfloat(3valkey)lcs(3valkey)mget(3valkey)mset(3valkey)msetnx(3valkey)psetex(3valkey)set(3valkey)setex(3valkey)setnx(3valkey)setrange(3valkey)strlen(3valkey)substr(3valkey)
the whole friend group. go say hi. ๐ซถโจ
and that's the page bestie!! this was Valkey 9.0.0, dated 2025-10-21, and the manual name is INCRBY(3valkey) โ remember her name because she will be on the test. ๐
๐ธ mwah, 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