Redis - String Incr Command


Advertisements

Redis INCR command is used to increment the integer value of a key by one. 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. This operation is limited to 64 bit signed integers.

Return Value

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

Syntax

Following is the basic syntax of Redis INCR command.

redis 127.0.0.1:6379> INCR KEY_NAME

Example

redis 127.0.0.1:6379> SET visitors 1000 
OK 
redis 127.0.0.1:6379> INCR visitors 
(integer) 1001 
redis 127.0.0.1:6379> GET visitors 
(integer) 1001
redis_strings.htm
Advertisements