Mysql replication invalidating query cache entries table
The old website had a 15 minute TTL cache and we knew that wasn’t going to cut it in the new website.
Visitors want to see new articles and updates to articles the minute they’re published, not 15 minutes later. Clicking on the article will retrieve and display the full article. The first picture is used as the headline picture, and is shown with the article summary in article lists.
This means that if you change that object (by calling setters or other state-changing methods on the object), you are actually changing the object in the cache! There are three ways around this: annotation along with the Spring directive to enable them, creates an aspect that surrounds the caching method. In case of a cache hit, the cached method return value is returned and the method is not executed at all.
In case of a cache miss, the method is executed, and after method invocation, Spring adds an entry to the cache: the key is determined by the method parameters, the value is the result of the method call.
A simple data model: Articles are imported from a CMS and inserted into the database by an importer application.
The articles are read from the database and presented by multiple redundant presentation applications: The presentation nodes do caching of pretty much everything, including the article lists and the articles, in the service layer.
We use the Spring declarative caching by means of the @Cacheable annotation: So our application is running.
returns a cached value you get a pointer to the object in the cache.Our visitors have viewed some articles and article lists and these are now cached, eternally, on both presentation nodes.Now an editor changes the title of one of the articles that are already cached.Spring offers a annotation for declarative cache eviction, but this only works if the caching and updating of the data happens in the same JVM.In our case, data is written in one JVM — the one running our importer — and read in several others — the presentation nodes.