INCRBY

Since 1.1.0Strings

Syntax

INCRBY key increment
  • Flags: fast, write
  • ACL categories: @fast, @string, @write
  • Arity: 3

Adds increment, a signed 64-bit integer, to the integer stored at key. A negative increment subtracts. A missing key counts as 0.

Reply

  • The value after the increment.
  • ERR increment or decrement would overflow if the result does not fit in 64 bits; the value is unchanged.
  • ERR value is not an integer or out of range if the value is not an integer.

Examples

> SET n 10
OK
> INCRBY n 5
(integer) 15
> INCRBY n -20
(integer) -5
> SET big 9223372036854775807
OK
> INCRBY big 1
(error) ERR increment or decrement would overflow