incr

abbr.increase (value, price, inventory, amount, production, etc.) increase;increasing increase;increased increase;incremental increase

redis INCR command syntax

Function: Increase the numerical value stored in key by one.

Syntax: INCR key

Description: If key does not exist, then the value of key will be initialized to 0 first, and then INCR will be executed operate. If the value contains the wrong type, or a value of type string cannot be represented as a number, an error is returned. The value of this operation is limited to 64-bit signed number representation.

Available versions: >= 1.0.0

Time complexity: O(1)

Return: The value of key after executing the INCR command.

redis INCR command example

redis> SET page_view 20
OK
redis> INCR page_view
(integer) 21
redis> GET page_view    # 数字值在 Redis 中以字符串的形式保存
"21"