Class LRUCacheFactory

java.lang.Object
org.apache.camel.support.LRUCacheFactory
Direct Known Subclasses:
DefaultLRUCacheFactory

public abstract class LRUCacheFactory extends Object
Factory to create LRUCache instances.
  • Field Summary

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    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)
    Deprecated.
    abstract <K, V> Map<K,V>
    createLRUWeakCache(int initialCapacity, int maximumCacheSize)
    Deprecated.
    abstract <K, V> Map<K,V>
    createLRUWeakCache(int initialCapacity, int maximumCacheSize, boolean stopOnEviction)
    Deprecated.
    Gets (and creates if needed) the LRUCacheFactory to use.
    static void
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • LRUCacheFactory

      public LRUCacheFactory()
  • Method Details

    • 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

      @Deprecated(since="4.2.0") public abstract <K, V> Map<K,V> createLRUWeakCache(int maximumCacheSize)
      Deprecated.
      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

      @Deprecated(since="4.2.0") public abstract <K, V> Map<K,V> createLRUWeakCache(int initialCapacity, int maximumCacheSize)
      Deprecated.
      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

      @Deprecated(since="4.2.0") public abstract <K, V> Map<K,V> createLRUWeakCache(int initialCapacity, int maximumCacheSize, boolean stopOnEviction)
      Deprecated.
      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