English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Incr Command

Redis Strings (string)

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

If the key does not exist, the key's value will be initialized to 0 first, and then the INCR operation will be performed.

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

The value of this operation is limited to 64 Signed numbers within the range of bit positions.

Syntax

The basic syntax of 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 executing the INCR command.

Online Examples

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 (string)