# TOUCH

> Mark keys as accessed and count how many exist.

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

```
TOUCH key [key ...]
```

- Group: Keys
- Complexity: O(N) for N keys
- HotKV Cloud: all plans
- On-Premise: no license needed

`TOUCH` records an access to each key that exists, which resets its idle time
(see [OBJECT IDLETIME](https://docs.hotkv.com/commands/object-idletime/index.md)) and counts towards its
access frequency under an LFU eviction policy. The values are not read or
changed. It counts as an access even for a connection that has turned on
`CLIENT NO-TOUCH`, since recording the access is the point of the command.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Always | Integer: the number of named keys that exist | Integer |

## Examples

```
127.0.0.1:6379> MSET a 1 b 2
OK
127.0.0.1:6379> TOUCH a b missing
(integer) 2
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[EXISTS](https://docs.hotkv.com/commands/exists/index.md), [OBJECT IDLETIME](https://docs.hotkv.com/commands/object-idletime/index.md),
[OBJECT FREQ](https://docs.hotkv.com/commands/object-freq/index.md)