Class LRUCacheFactory

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String FACTORY
      Factory key
    • Constructor Summary

      Constructors 
      Constructor Description
      LRUCacheFactory()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract <K,​V>
      Map<K,​V>
      createLRUCache​(int maximumCacheSize)
      Constructs an empty LRUCache instance with the specified maximumCacheSize, and will stop on eviction.
      abstract <K,​V>
      Map<K,​V>
      createLRUCache​(int initialCapacity, int maximumCacheSize)
      Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize, and will stop on eviction.
      abstract <K,​V>
      Map<K,​V>
      createLRUCache​(int initialCapacity, int maximumCacheSize, boolean stopOnEviction)
      Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.
      abstract <K,​V>
      Map<K,​V>
      createLRUCache​(int maximumCacheSize, Consumer<V> onEvict)
      Constructs an empty LRUCache instance with the specified maximumCacheSize, and will stop on eviction.
      abstract <K,​V>
      Map<K,​V>
      createLRUSoftCache​(int maximumCacheSize)
      Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
      abstract <K,​V>
      Map<K,​V>
      createLRUSoftCache​(int initialCapacity, int maximumCacheSize)
      Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
      abstract <K,​V>
      Map<K,​V>
      createLRUSoftCache​(int initialCapacity, int maximumCacheSize, boolean stopOnEviction)
      Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
      abstract <K,​V>
      Map<K,​V>
      createLRUWeakCache​(int maximumCacheSize)
      Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
      abstract <K,​V>
      Map<K,​V>
      createLRUWeakCache​(int initialCapacity, int maximumCacheSize)
      Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
      abstract <K,​V>
      Map<K,​V>
      createLRUWeakCache​(int initialCapacity, int maximumCacheSize, boolean stopOnEviction)
      Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
      static LRUCacheFactory getInstance()
      Gets (and creates if needed) the LRUCacheFactory to use.
      static void init()
      Initializes and creates the cache factory if not explicit set.
      static <K,​V>
      Map<K,​V>
      newLRUCache​(int maximumCacheSize)
      Constructs an empty LRUCache instance with the specified maximumCacheSize, and will stop on eviction.
      static <K,​V>
      Map<K,​V>
      newLRUCache​(int initialCapacity, int maximumCacheSize)
      Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize, and will stop on eviction.
      static <K,​V>
      Map<K,​V>
      newLRUCache​(int initialCapacity, int maximumCacheSize, boolean stopOnEviction)
      Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.
      static <K,​V>
      Map<K,​V>
      newLRUCache​(int maximumCacheSize, Consumer<V> onEvict)
      Constructs an empty LRUCache instance with the specified maximumCacheSize, and will stop on eviction.
      static <K,​V>
      Map<K,​V>
      newLRUSoftCache​(int maximumCacheSize)
      Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
      static <K,​V>
      Map<K,​V>
      newLRUSoftCache​(int initialCapacity, int maximumCacheSize)
      Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
      static <K,​V>
      Map<K,​V>
      newLRUSoftCache​(int initialCapacity, int maximumCacheSize, boolean stopOnEviction)
      Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
      static <K,​V>
      Map<K,​V>
      newLRUWeakCache​(int maximumCacheSize)
      Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
      static <K,​V>
      Map<K,​V>
      newLRUWeakCache​(int initialCapacity, int maximumCacheSize)
      Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
      static <K,​V>
      Map<K,​V>
      newLRUWeakCache​(int initialCapacity, int maximumCacheSize, boolean stopOnEviction)
      Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
      static void setLRUCacheFactory​(LRUCacheFactory cacheFactory)
      Use this to set a specific LRUCacheFactory instance, such as before starting Camel, that then avoids doing auto discovery of the cache factory via classpath.
    • Constructor Detail

      • LRUCacheFactory

        public LRUCacheFactory()
    • Method Detail

      • init

        public static void init()
        Initializes and creates the cache factory if not explicit set.
      • setLRUCacheFactory

        public static void setLRUCacheFactory​(LRUCacheFactory cacheFactory)
        Use this to set a specific LRUCacheFactory instance, such as before starting Camel, that then avoids doing auto discovery of the cache factory via classpath.
      • getInstance

        public static LRUCacheFactory getInstance()
        Gets (and creates if needed) the LRUCacheFactory to use.
      • newLRUCache

        public static <K,​V> Map<K,​V> newLRUCache​(int maximumCacheSize)
        Constructs an empty LRUCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • newLRUCache

        public static <K,​V> Map<K,​V> newLRUCache​(int maximumCacheSize,
                                                             Consumer<V> onEvict)
        Constructs an empty LRUCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • newLRUCache

        public static <K,​V> Map<K,​V> newLRUCache​(int initialCapacity,
                                                             int maximumCacheSize)
        Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize, and will stop on eviction.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • newLRUCache

        public static <K,​V> Map<K,​V> newLRUCache​(int initialCapacity,
                                                             int maximumCacheSize,
                                                             boolean stopOnEviction)
        Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        stopOnEviction - whether to stop service on eviction.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • newLRUSoftCache

        public static <K,​V> Map<K,​V> newLRUSoftCache​(int maximumCacheSize)
        Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • newLRUSoftCache

        public static <K,​V> Map<K,​V> newLRUSoftCache​(int initialCapacity,
                                                                 int maximumCacheSize)
        Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • newLRUSoftCache

        public static <K,​V> Map<K,​V> newLRUSoftCache​(int initialCapacity,
                                                                 int maximumCacheSize,
                                                                 boolean stopOnEviction)
        Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        stopOnEviction - whether to stop service on eviction.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • newLRUWeakCache

        public static <K,​V> Map<K,​V> newLRUWeakCache​(int maximumCacheSize)
        Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • newLRUWeakCache

        public static <K,​V> Map<K,​V> newLRUWeakCache​(int initialCapacity,
                                                                 int maximumCacheSize)
        Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • newLRUWeakCache

        public static <K,​V> Map<K,​V> newLRUWeakCache​(int initialCapacity,
                                                                 int maximumCacheSize,
                                                                 boolean stopOnEviction)
        Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        stopOnEviction - whether to stop service on eviction.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • createLRUCache

        public abstract <K,​V> Map<K,​V> createLRUCache​(int maximumCacheSize)
        Constructs an empty LRUCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • createLRUCache

        public abstract <K,​V> Map<K,​V> createLRUCache​(int maximumCacheSize,
                                                                  Consumer<V> onEvict)
        Constructs an empty LRUCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • createLRUCache

        public abstract <K,​V> Map<K,​V> createLRUCache​(int initialCapacity,
                                                                  int maximumCacheSize)
        Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize, and will stop on eviction.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • createLRUCache

        public abstract <K,​V> Map<K,​V> createLRUCache​(int initialCapacity,
                                                                  int maximumCacheSize,
                                                                  boolean stopOnEviction)
        Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        stopOnEviction - whether to stop service on eviction.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • createLRUSoftCache

        public abstract <K,​V> Map<K,​V> createLRUSoftCache​(int maximumCacheSize)
        Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • createLRUSoftCache

        public abstract <K,​V> Map<K,​V> createLRUSoftCache​(int initialCapacity,
                                                                      int maximumCacheSize)
        Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • createLRUSoftCache

        public abstract <K,​V> Map<K,​V> createLRUSoftCache​(int initialCapacity,
                                                                      int maximumCacheSize,
                                                                      boolean stopOnEviction)
        Constructs an empty LRUSoftCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        stopOnEviction - whether to stop service on eviction.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • createLRUWeakCache

        public abstract <K,​V> Map<K,​V> createLRUWeakCache​(int maximumCacheSize)
        Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • createLRUWeakCache

        public abstract <K,​V> Map<K,​V> createLRUWeakCache​(int initialCapacity,
                                                                      int maximumCacheSize)
        Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • createLRUWeakCache

        public abstract <K,​V> Map<K,​V> createLRUWeakCache​(int initialCapacity,
                                                                      int maximumCacheSize,
                                                                      boolean stopOnEviction)
        Constructs an empty LRUWeakCache instance with the specified maximumCacheSize, and will stop on eviction.
        Parameters:
        initialCapacity - the initial capacity.
        maximumCacheSize - the max capacity.
        stopOnEviction - whether to stop service on eviction.
        Throws:
        IllegalArgumentException - if the initial capacity is negative