获取所有 Redis 键和上次访问时间的列表

Get list of all Redis keys and last access time

如何让 Redis 在上次访问时显示所有当前键?最好是某种机器可读的形式,但我会尽我所能。

如果在传送门上使用redis-cli command命令,可以使用下面的方法获取所有的key,然后一一获取上次访问的时间

>SET title "The Hobbit"
OK
>GET title
"The Hobbit"
>KEYS *
KEYS command is unsupported. Sending "SCAN 0 COUNT 1000 MATCH *" instead.
1) "0"
2) 1) "title"
>object idletime title
(integer) 126

如果用代码,就方便多了,实现的方法也很多

你可以参考下面post.

Delete redis keys that have been inactive for 30 days