Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

TOUCH

Last updated
TOUCH key [key ...]
Group
Keys
Complexity
O(N) for N keys
Arity
-2 (at least 2 words, counting the command name)
Flags
read-only, fast
Keys
first 1, last final argument, step 1
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) 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.

Case RESP2 RESP3
Always Integer: the number of named keys that exist Integer
127.0.0.1:6379> MSET a 1 b 2
OK
127.0.0.1:6379> TOUCH a b missing
(integer) 2

Same as Redis 7 and Valkey 8.

EXISTS, OBJECT IDLETIME, OBJECT FREQ