Non-blocking Asynchronous self populating cache with Ehcache
Suppose you would like to implement the following algorithm :
- try to get an element from the cache
- if the element is not expired
- serve the value
- else
- serve the expired value
- refresh the element in the background
Ehcache doesn't provide an out-of-the-box solution for this.
Here is an Ehcache decorator that does just that :