Skip to main content
Use INCR to add one to the integer stored at a key and get the result. A missing key counts as 0, so the first call returns 1 and no initialization is needed. The value must be the string form of a 64-bit signed integer; anything else returns an error, as does an overflow. The read, the addition, and the write are one atomic step, so concurrent callers each receive a distinct number and no increment is lost. That property is what makes it the basis for counters, id generators, and rate limiters, usually combined with EXPIRE to reset the count for each window.

Syntax

Arguments

Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Related topics

INCRINCRBYINCRBYFLOAT