Package com.ibm.icu.impl
Class SoftCache<K,V,D>
- java.lang.Object
-
- com.ibm.icu.impl.CacheBase<K,V,D>
-
- com.ibm.icu.impl.SoftCache<K,V,D>
-
- Type Parameters:
K- Cache lookup key typeV- Cache instance value typeD- Data type for creating a new instance value
public abstract class SoftCache<K,V,D> extends CacheBase<K,V,D>
Generic, thread-safe cache implementation, storing SoftReferences to cached instances. To use, instantiate a subclass which implements the createInstance() method, and call get() with the key and the data. The get() call will use the data only if it needs to call createInstance(), otherwise the data is ignored. By using SoftReferences to instances, the Java runtime can release instances once they are not used any more at all. If such an instance is then requested again, the get() method will call createInstance() again and also create a new SoftReference. The cache holds on to its map of keys to SoftReferenced instances forever.
-
-
Constructor Summary
Constructors Constructor Description SoftCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VgetInstance(K key, D data)Retrieves an instance from the cache.-
Methods inherited from class com.ibm.icu.impl.CacheBase
createInstance
-
-
-
-
Method Detail
-
getInstance
public final V getInstance(K key, D data)
Description copied from class:CacheBaseRetrieves an instance from the cache. Calls createInstance(key, data) if the cache does not already contain an instance with this key. Ignores data if the cache already contains an instance with this key.- Specified by:
getInstancein classCacheBase<K,V,D>- Parameters:
key- Cache lookup key for the requested instancedata- Data for createInstance() if the instance is not already cached- Returns:
- The requested instance
-
-