Updating selfpopulatingcache example
I recently had to sit down and figure out exactly how it works, and thought I’d take a moment to write it up. Because open source development is more about individuals than organisations, Wotif staff members don’t really have much to do with ehcache development. You can monitor cache hits and misses in detail by turning the logging for the up.
it was initially written at Wotif, to overcome problems with the Jakarta JCS project. Since it was originally released, ehcache has grown somewhat and has a modest direct following. If you regularly see the same set of objects going in and out of the cache, you know you need a larger cache to be truly effective.
The pattern delegates SOR reading and writing activies to the cache, so that application code is absolved of this responsibility.
To implement the cache-as-sor pattern, use a combination of the following read and write patterns: .
The Blocking Cache class is a cache decorator, which allows concurrent read access to elements already in the cache.
Compare the appearance of the read-through pattern code to the code provided in the cache-aside pattern.
(The full example is provided at the end of this document that includes a read-through and write-through implementation).
Since it would be an Eh Cache type of cache, it would have the properties of the cache configured in the file, and we are especially interested in the expiration property if we want to refresh this cache at some interval.
The cache knows how to populate itself, after expiration it would again use the method to retrieve the new values, so the second problem of expiration would be solved.
Search for updating selfpopulatingcache example:
I use EHCache to maintain a mostly read-only cache of results from database queries. However, there is one table which needs an odd access method that is causing me grief.