Class CaffeineLRUCache<K,​V>

  • All Implemented Interfaces:
    com.github.benmanes.caffeine.cache.RemovalListener<K,​V>, Serializable, Map<K,​V>, org.apache.camel.support.LRUCache<K,​V>
    Direct Known Subclasses:
    CaffeineLRUSoftCache, CaffeineLRUWeakCache

    @Deprecated
    public class CaffeineLRUCache<K,​V>
    extends Object
    implements org.apache.camel.support.LRUCache<K,​V>, com.github.benmanes.caffeine.cache.RemovalListener<K,​V>, Serializable
    Deprecated.
    A cache that uses a near optional LRU Cache.

    The Cache is implemented by Caffeine which provides an efficient cache.

    If this cache stores Service then this implementation will on eviction invoke the Service.stop() method, to auto-stop the service.

    Use LRUCacheFactory to create a new instance (do not use the constructor).

    See Also:
    LRUCacheFactory, CaffeineLRUSoftCache, CaffeineLRUWeakCache, Serialized Form
    • Field Detail

      • hits

        protected final LongAdder hits
        Deprecated.
      • misses

        protected final LongAdder misses
        Deprecated.
      • evicted

        protected final LongAdder evicted
        Deprecated.
    • Constructor Detail

      • CaffeineLRUCache

        public CaffeineLRUCache​(int maximumCacheSize)
        Deprecated.
        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
      • CaffeineLRUCache

        public CaffeineLRUCache​(int initialCapacity,
                                int maximumCacheSize)
        Deprecated.
        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
      • CaffeineLRUCache

        public CaffeineLRUCache​(int initialCapacity,
                                int maximumCacheSize,
                                boolean stopOnEviction)
        Deprecated.
        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
      • CaffeineLRUCache

        public CaffeineLRUCache​(int initialCapacity,
                                int maximumCacheSize,
                                boolean stopOnEviction,
                                boolean soft,
                                boolean weak,
                                boolean syncListener)
        Deprecated.
        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.
        soft - whether to use soft values a soft cache (default is false)
        weak - whether to use weak keys/values as a weak cache (default is false)
        syncListener - whether to use synchronous call for the eviction listener (default is false)
        Throws:
        IllegalArgumentException - if the initial capacity is negative
      • CaffeineLRUCache

        public CaffeineLRUCache​(int initialCapacity,
                                int maximumCacheSize,
                                Consumer<V> evict,
                                boolean soft,
                                boolean weak,
                                boolean syncListener)
        Deprecated.
        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.
        evict - callback for evicted elements
        soft - whether to use soft values a soft cache (default is false)
        weak - whether to use weak keys/values as a weak cache (default is false)
        syncListener - whether to use synchronous call for the eviction listener (default is false)
        Throws:
        IllegalArgumentException - if the initial capacity is negative
    • Method Detail

      • get

        public V get​(Object o)
        Deprecated.
        Specified by:
        get in interface Map<K,​V>
      • size

        public int size()
        Deprecated.
        Specified by:
        size in interface Map<K,​V>
      • isEmpty

        public boolean isEmpty()
        Deprecated.
        Specified by:
        isEmpty in interface Map<K,​V>
      • containsKey

        public boolean containsKey​(Object o)
        Deprecated.
        Specified by:
        containsKey in interface Map<K,​V>
      • containsValue

        public boolean containsValue​(Object o)
        Deprecated.
        Specified by:
        containsValue in interface Map<K,​V>
      • put

        public V put​(K k,
                     V v)
        Deprecated.
        Specified by:
        put in interface Map<K,​V>
      • remove

        public V remove​(Object o)
        Deprecated.
        Specified by:
        remove in interface Map<K,​V>
      • putAll

        public void putAll​(Map<? extends K,​? extends V> map)
        Deprecated.
        Specified by:
        putAll in interface Map<K,​V>
      • clear

        public void clear()
        Deprecated.
        Specified by:
        clear in interface Map<K,​V>
      • keySet

        public Set<K> keySet()
        Deprecated.
        Specified by:
        keySet in interface Map<K,​V>
      • onRemoval

        public void onRemoval​(K key,
                              V value,
                              com.github.benmanes.caffeine.cache.RemovalCause cause)
        Deprecated.
        Specified by:
        onRemoval in interface com.github.benmanes.caffeine.cache.RemovalListener<K,​V>
      • getHits

        public long getHits()
        Deprecated.
        Gets the number of cache hits
        Specified by:
        getHits in interface org.apache.camel.support.LRUCache<K,​V>
      • getMisses

        public long getMisses()
        Deprecated.
        Gets the number of cache misses.
        Specified by:
        getMisses in interface org.apache.camel.support.LRUCache<K,​V>
      • getEvicted

        public long getEvicted()
        Deprecated.
        Gets the number of evicted entries.
        Specified by:
        getEvicted in interface org.apache.camel.support.LRUCache<K,​V>
      • getMaxCacheSize

        public int getMaxCacheSize()
        Deprecated.
        Returns the maxCacheSize.
        Specified by:
        getMaxCacheSize in interface org.apache.camel.support.LRUCache<K,​V>
      • resetStatistics

        public void resetStatistics()
        Deprecated.
        Rest the cache statistics such as hits and misses.
        Specified by:
        resetStatistics in interface org.apache.camel.support.LRUCache<K,​V>
      • cleanUp

        public void cleanUp()
        Deprecated.
        Specified by:
        cleanUp in interface org.apache.camel.support.LRUCache<K,​V>