Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the last time a given Redis key was accessed

I'd like to view the time of most recent access for a specific key on my redis server.

I know that this information is stored for each key because it is used in redis's LRU algorithm for eliminating old keys.

Is there an easy way to see this information for a given key?

like image 572
Peter Berg Avatar asked Oct 07 '14 21:10

Peter Berg


1 Answers

You can use the OBJECT IDLETIME command for this purpose. It returns the number of seconds since the key was accessed, but If you need the time just subtract the reply from now().

like image 66
Itamar Haber Avatar answered Sep 20 '22 06:09

Itamar Haber