Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the need of UpdateTimestampsCache in EhCache configuration file?

I am not able to understand the exact use of UpdateTimestampsCache in ehCache ? I googled a lot but haven't anything except below statement.

Tracks the time stamps of the most recent updates to particular tables.

But whats the role of UpdateTimestampsCache in second level cache ?

like image 734
Saurabh Oza Avatar asked Jan 29 '23 17:01

Saurabh Oza


1 Answers

When you use the Hibernate query cache (i.e. the one that stores the results from queries), it will use this cache store the time stamps of the most recent updates to tables. It then can compare the time at which each table was last updated and when the query's result was cached. If the query's result was cached and the tables haven't changed, it's safe to return the cached result. If, on the other hand, there has been changes to the tables involved in the query since the result was cached, we can't know for sure the result is still correct and the cached result will be discarded and hit the DB instead... I hope this makes some sense.

Know that, because of the cost of maintaining the UpdateTimestampsCache, it may be less efficient to use the query cache... especially in cases where data in tables change a lot...

like image 171
Alex Snaps Avatar answered Feb 07 '23 11:02

Alex Snaps