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 executed.

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 The value is limited to

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    # 数字值在 Redis 中以字符串的形式保存
"21"

Redis Strings (string)