Redis - String Incrby Command



Redis INCRBY command is used to increment 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 key after the increment.

Syntax

Following is the basic syntax of Redis INCRBY command.

redis 127.0.0.1:6379> INCRBY KEY_NAME INCR_AMOUNT

Example

redis 127.0.0.1:6379> SET visitors 1000 
OK 
redis 127.0.0.1:6379> INCRBY visitors 5 
(integer) 1005 
redis 127.0.0.1:6379> GET visitors 
(integer) 1005
redis_strings.htm
Advertisements