In EHCache, is there a way to implement some kind of a db listener where the cahce will auto update if the data is out of sync? (e.g as soon as the user requests for data, the cahce checks if the data is out of sync, if yes...updates itself and returns the data, if not...just return the data from the cache)If someone can point me which part of the specification highlights this use, that would be awesome!
The goal is to always provide the latest data to the user. So I am guessing a timed refresh mechanism will not do as the data can change anytime.
EHCAche is not mandatory to use in my case, so any mechanism that satisfies this will be most welcome...
Thanks!!
Open-source Ehcache offers a limited version of persistence, as noted in this document. Fast Restart provides enterprise-ready crash resilience with an option to store a fully consistent copy of the cache on the local disk at all times.
EhCache is a widely used, pure Java cache that can be easily integrated with most popular Java frameworks, such as Spring and Hibernate. It is often considered to be the most convenient choice for Java applications since it can be integrated into projects easily.
In this article, we will introduce Ehcache, a widely used, open-source Java-based cache. It features memory and disk stores, listeners, cache loaders, RESTful and SOAP APIs and other very useful features.
For EhCache this is what I believe you are looking for. If you would not like to do timed refresh (even though it is a simple solution), triggers or a message bus based update would be the way to go. You can perform some statistics and see update frequency once the triggering has been established and switch to a timed update with sufficient frequency to satisfy Nyquist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With