- All Implemented Interfaces:
- java.util.Map<K,V>
public class SoftRefMap<K,V>
extends java.lang.Object
implements java.util.Map<K,V>
A very simple cache map implementation using soft references around the keys. This class is very much NOT
thread-safe, so if there is any multi- threaded use, you must wrap in Collections.synchronizedMap(). Also,
containsValue(), entrySet(), and values() are not supported. This class also doesn't prune the keys for cleared
references aggressivly - you can prune them yourself by calling pruneClearedReferences()
XXX Colby says: just happened upon this... might be worth looking into replacing this class with the Google
Collections MapMaker, which supports soft keys, concurrency, auto pruning, and a value generation function.