[Opensymphony-oscache] threading issues with NeedsRefreshException

Gregory Block <[email protected]> Thu, 21 Jul 2005 03:23:36 CDT
Newsgroups gmane.comp.java.open-symphony.os-cache
Message-ID <25532460.1121934246741.JavaMail.os-j2ee@opensymphony01.contegix.com>
I do this right now, so I don't see the point/problem.

Just:

 - Grab the cached value,
 - Queue an update request on your own worker pool to retrieve the content, ensuring that the queue does not already contain a request for that content,
 - Cancel the update,
 - Return the cached value.

In your queue, process the data request and update your cache asynchronously from the fetch process.

If there's nothing in cache in the first place, cancel the update, fire off the worker, and synchronously wait for the worker's response to your request; as others come along with the same request, they'll block on the same response from the work queue, if you've done it right, and then all the blocking happens in your code instead of in OSCache.

I hardly see the point in the latter, but hey.  We can all cry over the fact that the first request is going to yield a long wait for data, but that's the biz - either improve the load time, preload the data, or restructure your design.  There aren't any other options.

---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=4200&messageID=11070#11070