Easy Tutorial
❮ Strings Decr Redis Transactions ❯

Redis Incr Command

Redis Strings

The Redis Incr command increments the numeric value stored in the key by one.

If the key does not exist, the value of the key is initially set to 0 before performing the INCR operation.

If the value contains the wrong type, or if the string value cannot be represented as a number, an error is returned.

The value for this operation is limited to a 64-bit signed number representation.

Syntax

The basic syntax for the redis Incr command is as follows:

redis 127.0.0.1:6379> INCR KEY_NAME

Available Versions

= 1.0.0

Return Value

The value of the key after the INCR command is executed.

Example

redis> SET page_view 20
OK

redis> INCR page_view
(integer) 21

redis> GET page_view    # Numeric values are stored as strings in Redis
"21"

Redis Strings

❮ Strings Decr Redis Transactions ❯