I've implemented a mutable SoftCache. I felt as though the tradeoffs made it worth using a ConcurrentHashMap as the base for SoftCache.

SoftReference objects are mutable (and tied to a specific instance of ReferenceQueue). ReferenceQueue is mutable. Using an immutable map as the base for SoftCache would cost {O(n)} when removing cleared SoftReference objects from the cache.

If immutability is desirable, I also have an implementation of an immutable SoftCache, but it suffers from the above {O(n)} cost.

Paul Stadig
added a comment - 16/Jun/12 8:14 AM - edited I've implemented a mutable SoftCache. I felt as though the tradeoffs made it worth using a ConcurrentHashMap as the base for SoftCache.
SoftReference objects are mutable (and tied to a specific instance of ReferenceQueue). ReferenceQueue is mutable. Using an immutable map as the base for SoftCache would cost {O(n)} when removing cleared SoftReference objects from the cache.
If immutability is desirable, I also have an implementation of an immutable SoftCache, but it suffers from the above {O(n)} cost.

I have no problem with internal mutability in the cache impls, so that immutable code might not be needed. I've pushed the 0.7.0-SNAPSHOT version with your additions and will run it through the paces post-haste. Thank you for tackling this Paul, it's a huge help.

Fogus
added a comment - 19/Jun/12 6:53 AM I have no problem with internal mutability in the cache impls, so that immutable code might not be needed. I've pushed the 0.7.0-SNAPSHOT version with your additions and will run it through the paces post-haste. Thank you for tackling this Paul, it's a huge help.