INCRBY

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Increment by a given integer

Increments by the specified number.
If the key does not exist in the database, 0 is used as the base, the given number is added or subtracted, and the result is returned.

Example

Command>incrby key 10
Result>10
Command>incrby key 20
Result>30

View animation



Negative numbers are allowed

You can also specify a negative number.

Example

Command>incrby key -10
Result>-10
Command>incrby key -20
Result>-30

View animation



Error

A decimal value causes an error.

Example

Command>set key 10
Result>OK
Command>incrby key 2.5
Result>ERR value is not an integer or out of range


Syntax

INCRBY key increment (integer)

  • Available since version 1.0.0.
  • Time complexity is O(1).
Related commands INCR, DECRBY, INCRBYFLOAT
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< DECR INCRBY DECRBY >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.