Class CaffeineCache<K>

  • Type Parameters:
    K - The type of the key to cache
    All Implemented Interfaces:
    org.apache.camel.resume.cache.ResumeCache<K>

    public class CaffeineCache<K>
    extends Object
    implements org.apache.camel.resume.cache.ResumeCache<K>
    This is a simple cache implementation that uses Caffeine to store the resume offsets
    • Constructor Detail

      • CaffeineCache

        public CaffeineCache​(long cacheSize)
        Builds a new cache with the given cache size
        Parameters:
        cacheSize - the cache size
      • CaffeineCache

        public CaffeineCache​(com.github.benmanes.caffeine.cache.Cache<K,​Object> cache,
                             long cacheSize)
        Builds a new instance of this object
        Parameters:
        cache - an instance of a pre-constructed cache object
        cacheSize - the size of the pre-constructed cache object
    • Method Detail

      • contains

        public boolean contains​(K key,
                                Object entry)
        Specified by:
        contains in interface org.apache.camel.resume.cache.ResumeCache<K>
      • add

        public void add​(K key,
                        Object offsetValue)
        Specified by:
        add in interface org.apache.camel.resume.cache.ResumeCache<K>
      • get

        public Object get​(K key)
        Specified by:
        get in interface org.apache.camel.resume.cache.ResumeCache<K>
      • get

        public <T> T get​(K key,
                         Class<T> clazz)
        Specified by:
        get in interface org.apache.camel.resume.cache.ResumeCache<K>
      • computeIfAbsent

        public Object computeIfAbsent​(K key,
                                      Function<? super K,​? super Object> mapping)
        Specified by:
        computeIfAbsent in interface org.apache.camel.resume.cache.ResumeCache<K>
      • computeIfPresent

        public Object computeIfPresent​(K key,
                                       BiFunction<? super K,​? super Object,​? super Object> remapping)
        Specified by:
        computeIfPresent in interface org.apache.camel.resume.cache.ResumeCache<K>
      • isFull

        public boolean isFull()
        Specified by:
        isFull in interface org.apache.camel.resume.cache.ResumeCache<K>
      • capacity

        public long capacity()
        Specified by:
        capacity in interface org.apache.camel.resume.cache.ResumeCache<K>
      • forEach

        public void forEach​(BiFunction<? super K,​? super Object,​Boolean> action)
        Specified by:
        forEach in interface org.apache.camel.resume.cache.ResumeCache<K>