What's new in Valkey 9.0? Discover new features and improvements. Read the announcement.

TOUCH

Returns the number of existing keys out of those specified after updating the time they were last accessed.

Usage
TOUCH key ...
Complexity
O(N) where N is the number of keys that will be touched.
Since
3.2.1
ACL Categories
@fast, @keyspace, @read
Command flags
READONLY, FAST

Alters the last access time of a key(s). A key is ignored if it does not exist.

Examples

127.0.0.1:6379> SET key1 "Hello"
OK
127.0.0.1:6379> SET key2 "World"
OK
127.0.0.1:6379> TOUCH key1 key2
(integer) 2

Replies

RESP2

Integer reply: the number of touched keys.

RESP3

Integer reply: the number of touched keys.