Mtouch
Bun

method

RedisClient.touch

...keys: KeyLike[]
): Promise<number>;

Alters the last access time of one or more keys

A key is ignored if it does not exist. The command returns the number of keys that were touched.

This command is useful in conjunction with maxmemory-policy allkeys-lru / volatile-lru to change the last access time of keys for eviction purposes.

@param keys

One or more keys to touch

@returns

Promise that resolves with the number of keys that were touched

await redis.set("key1", "Hello");
await redis.set("key2", "World");
const touched = await redis.touch("key1", "key2", "key3");
console.log(touched); // 2 (key3 doesn't exist)

Referenced types

type KeyLike = string | ArrayBufferView | Blob