I'm trying to accomplish a according to me a pretty common data cache strategy using Hibernate. But I can't find a nice way to do it. Here is what I want to do:
1. Select all data all att once and store it in 2nd level cache (disk and memory)
2. Set an expiry for all data on 2 days. But I don't want the cache to remove the expired entries.
3. When an expired entry is fetched I want to serve that expired data but start the batch fetch in an other thread that fetches all the data in the background and updates the cache.
Any suggestions on how to implement this?