TOUCH · Valkey

TOUCH

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

Usage

TOUCH key [key…]

Description

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

Reply

Integer reply: the number of touched keys.

Complexity

O(N) where N is the number of keys that will be touched.

ACL Categories

@fast @keyspace @read

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

History

See also

COPY, DEL, DUMP, EXISTS, EXPIRE, EXPIREAT, EXPIRETIME, KEYS, MIGRATE, MOVE, OBJECT, OBJECT ENCODING, OBJECT FREQ, OBJECT HELP, OBJECT IDLETIME, OBJECT REFCOUNT, PERSIST, PEXPIRE, PEXPIREAT, PEXPIRETIME, PTTL, RANDOMKEY, RENAME, RENAMENX, RESTORE, SCAN, SORT, SORT_RO, TTL, TYPE, UNLINK, WAIT, WAITAOF.