# INCR

> Add 1 to the integer stored at a key.

URL: https://docs.hotkv.com/commands/incr/

```
INCR key
```

- Group: String
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`INCR` adds 1 to the number stored at `key` and returns the new value. A
missing key counts as `0`, so the first `INCR` creates it with the value `1`.
The value must be the decimal text of a signed 64-bit integer. The key keeps
its time to live, which makes `INCR` with [EXPIRE](https://docs.hotkv.com/commands/expire/index.md) a common
building block for counters and rate limits.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Always | Integer: the value after the increment | Integer |

Errors:

- `ERR value is not an integer or out of range` when the stored value is not
  an integer.
- `ERR increment or decrement would overflow` when the result does not fit in
  a signed 64-bit integer.
- `WRONGTYPE` when the key holds a value that is not a string.

## Examples

```
127.0.0.1:6379> INCR visits
(integer) 1
127.0.0.1:6379> INCR visits
(integer) 2
127.0.0.1:6379> SET name "ada"
OK
127.0.0.1:6379> INCR name
(error) ERR value is not an integer or out of range
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[INCRBY](https://docs.hotkv.com/commands/incrby/index.md), [DECR](https://docs.hotkv.com/commands/decr/index.md),
[INCRBYFLOAT](https://docs.hotkv.com/commands/incrbyfloat/index.md), [GCRA.LIMIT](https://docs.hotkv.com/commands/gcra-limit/index.md)