INCRBY(3valkey)

๐Ÿ“ฆ
version 9.0.6 ยท 2 versions
, in fedora 44

๐Ÿ’– 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 ๐Ÿ’œ

O(1)

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 ๐Ÿ‘‘

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