Latest web development tutorials

Redis Incr command

Redis string (string)

Redis Incr command key stored digital value is incremented by one.

If the key is not present, then the value of the key will first be initialized to 0, and then perform operations INCR.

If the value type or string type containing the error can not be expressed as a number, it returns an error.

This operation is limited to the value of 64-bit (bit) signed within the digital representation.

grammar

redis Incr basic command syntax is as follows:

redis 127.0.0.1:6379> INCR KEY_NAME 

Available versions

> = 1.0.0

return value

INCR value after executing the command key.

Examples

redis> SET page_view 20
OK

redis> INCR page_view
(integer) 21

redis> GET page_view    # 数字值在 Redis 中以字符串的形式保存
"21"

Redis string (string)