We have a high-performance Java (J2SE) middleware application where latency is paramount. It uses some persistent data stored in an outdated database, where an outdated application can sometimes modify data. Due to the latency requirement, we plan to cache persistent data using JPA with Hibernate and possibly a cache provider such as Ehcache.
However, when persistent data is updated (by an outdated application), we should be notified as soon as possible. I thought about the expiration of the cache, but then the cache will not be updated until the application makes the next request for data - at this point the latency will be executed due to re-reading the database.
Ideally, we need a cache to return an obsolete value, and in the background, the cache is updated / updated with the latest value from the database at regular intervals.
Is this possible with Ehcache? I have seen SelfPopulatingCache and CacheLoader, but it looks like I am doing a lot of work (I would have to write code for each object). Also, does anyone have an example implementation of CacheLoader? I was hoping for the async update option in Query Cache.
Are there any other technologies that could provide a solution? We are not affiliated with a JPA provider or cache provider.
Can Spring @Cacheable provide a solution? I saw spring ehcache cachable mentions the self-propagating cache area, but it is not clear what that means.
Thanks in advance.
java spring caching jpa ehcache
martin
source share