Class CacheUtilities


  • public class CacheUtilities
    extends java.lang.Object
    Utilities for creating caches
    • Constructor Summary

      Constructors 
      Constructor Description
      CacheUtilities()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CacheUtilities

        public CacheUtilities()
    • Method Detail

      • 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