Class CacheUtilities

java.lang.Object
org.glassfish.hk2.utilities.cache.CacheUtilities

public class CacheUtilities extends Object
Utilities for creating caches
  • 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 method WeakCARCache.clearStaleReferences() is called
      Parameters:
      computable - The computable that is used to get the V from the given K
      maxSize - The maximumSize of the cache
      isWeak - 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