INCRBY

Redis Developer Course Redis Cloud Service Redis-Gate Server

Increment by the given number(integer)

Increment(adding) the integer value of a key by the given number.
If the key does not exist in the database, it is set to 0 before performing the operation, add the given number and return it.
Usage is INCRBY key integer.

Return value

Integer reply: the value of key after the increment

Example

command>incrby key 10
result>10
command>incrby key 20
result>30

Animation



Allow negative integer input

Example

command>incrby key -10
result>-10
command>incrby key -20
result>-30

Animation



Error

If you enter a decimal point, an error occurs.

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 1.0.0.
  • Time complexity: O(1)
Related Commands INCR, DECRBY, INCRBYFLOAT
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

To practice the command, click here to run Redis Web Client


<< DECR INCRBY DECRBY >>

Click for a question or to see comments.  Comments :    Viewed :

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