INCR

Since 1.1.0Strings

Syntax

INCR key
  • Flags: fast, write
  • ACL categories: @fast, @string, @write
  • Arity: 2

Adds 1 to the integer stored at key. A missing key counts as 0. The value must be a string that reads as a signed 64-bit integer.

Reply

  • The value after the increment.
  • ERR increment or decrement would overflow if the value is already the largest 64-bit integer, 9223372036854775807; the value is unchanged.
  • ERR value is not an integer or out of range if the value is not an integer.
  • A WRONGTYPE error if the key is not a string.

Examples

> SET n 10
OK
> INCR n
(integer) 11
> INCR missing
(integer) 1
> SET big 9223372036854775807
OK
> INCR big
(error) ERR increment or decrement would overflow

Before 1.2, INCR at the largest integer wrapped around to -9223372036854775808.