DECRBY

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

Decrement by a specified integer

Decrements by the specified number. In other words, it multiplies the specified number by -1.
If the key does not exist, it uses 0 as the base and returns the specified number as a negative.

Example

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

View animation



Negative values are allowed

You can also enter a negative number.

Example

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

View animation



Error

Entering a decimal point causes an error.

Example

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


Syntax

DECRBY key decrement(integer)

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

<< INCRBY DECRBY INCRBYFLOAT >>

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