views:

70

answers:

1

Is it possible to have cached queries asynchronous, so that no frontend user actually has to wait for a heavy query to finish? (I.e. heavy query is running as background thread, while (expired) data is delivered from cache.

Use case: A web page displaying data, needing some time (too long to wait for when requesting a page) to be collected from the database. Simply caching the data for one hour means that every hour one user has to wait for the query to finish.

I would like to have something like this: The first user to request (expired) data from cache, will be delivered expired data. In the background, a separate thread is started which will update the cached data from the database. The next user will see fresh data.

Is there a standard solution for this, without having to do the caching oneself? Ideally, using ehcache & springmodules.

Thanks :)

A: 

Obviously, there is no out of the box solution.

We are going to implement our own interceptor.

PeterP