Redis - String Decrby Command



Redis DECRBY command is used to decrement the number stored at the key by the specified value. If the key does not exist, it is set to 0 before performing the operation. An error is returned, if the key contains a value of the wrong type or contains a string that cannot be represented as an integer.

Return Value

Integer reply, the value of the key after the increment.

Syntax

Following is the basic syntax of Redis DECRBY command.

redis 127.0.0.1:6379> DECRBY KEY_NAME DECREMENT_AMOUNT

Example

redis 127.0.0.1:6379> SET visitors 1000 
OK 
redis 127.0.0.1:6379> DECRBY visitors 5 
(integer) 995 
redis_strings.htm
Advertisements