Alexsighy's avatar

Cache last updated x minutes ago

Hello, I want to cache some sum() and average() queries to display on an admin dashbord, stuff like clients, total views etc.

The idea is to optimize this by adding cache and removing the cache everytime a change happens. Is it possible to get when the cache was created and displayed it like "Last updated 5 minutes ago"?

0 likes
3 replies
Snapey's avatar
Snapey
Best Answer
Level 122

cache a timestamp along with the data?

1 like
tykus's avatar

There is a KeyWritten cache event fired whenever a value is put to the cache; you can hook into that event to set another value with the current datetime.

1 like

Please or to participate in this conversation.