[concurrency-interest] Question: Concurrent Memoizer pattern withSoftHashMap
tim at peierls.net
Tue Nov 20 20:01:51 EST 2007
On Nov 20, 2007 7:04 PM, David Holmes <dcholmes at optusnet.com.au> wrote:
> Is there a reason you can't simply wrap the Future in a SoftReference
> directly so that your ConcurrentHashMap cache is mapping from K ->
> SoftReference<Future<V>> ? If you find a value with a null referent then
> can remove the WeakReference from the map and replace with a new one. You
> might need additional expunging logic if your cache might accumulate
I found this surprisingly hard to get right. I have code that I would have
to figure how to release that lets you build Memoizers using plain, soft, or
weak references. The plain version is just standard Memoizer.
But closer at hand is the Google Collections library and ReferenceCache from
the Guice codebase. Somewhere in there you can find what you need.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest