Package org.apache.camel.support
Class LRUCacheFactory
java.lang.Object
org.apache.camel.support.LRUCacheFactory
- Direct Known Subclasses:
DefaultLRUCacheFactory
Factory to create
LRUCache
instances.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract <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
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.
-
Field Details
-
FACTORY
Factory key- See Also:
-
-
Constructor Details
-
LRUCacheFactory
public LRUCacheFactory()
-
-
Method Details
-
init
public static void init()Initializes and creates the cache factory if not explicit set. -
setLRUCacheFactory
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
Gets (and creates if needed) the LRUCacheFactory to use. -
newLRUCache
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
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
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
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
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
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
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
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
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
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
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
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
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
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
-