Class CacheUtilities
java.lang.Object
org.glassfish.hk2.utilities.cache.CacheUtilities
Utilities for creating caches
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> WeakCARCache <K, V> createWeakCARCache
(Computable<K, V> computable, int maxSize, boolean isWeak) Returns a WEAKCarCache with the given computable and the given maximum value size of the cache.
-
Constructor Details
-
CacheUtilities
public CacheUtilities()
-
-
Method Details
-
createWeakCARCache
public static <K,V> WeakCARCache<K,V> createWeakCARCache(Computable<K, V> computable, int maxSize, boolean isWeak) Returns a WEAKCarCache with the given computable and the given maximum value size of the cache. The Cache returned will have weak keys, so that when the key becomes only weakly reachable it will be removed from the cache. However, values will only be removed from the Cache when an operation is performed on the cache or the methodWeakCARCache.clearStaleReferences()
is called- Parameters:
computable
- The computable that is used to get the V from the given KmaxSize
- The maximumSize of the cacheisWeak
- if true this will keep weak keyes, if false the keys will be hard and will not go away even if they do not exist anywhere else but this cache- Returns:
- A WeakCARCache that is empty
-