Class CacheSupport


  • public final class CacheSupport
    extends java.lang.Object
    A utility class for creating Caffeine cache instances
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K,​V>
      com.github.benmanes.caffeine.cache.Cache<K,​V>
      createCache​(int maximumSize)
      Create a cache with a size-based eviction policy
      static <K,​V>
      com.github.benmanes.caffeine.cache.Cache<K,​V>
      createCache​(int maximumSize, boolean recordStats)
      Create a cache with a size-based eviction policy
      static <K,​V>
      com.github.benmanes.caffeine.cache.Cache<K,​V>
      createCache​(int maximumSize, java.time.Duration duration)
      Create a cache with both size and time-based eviction policies
      static <K,​V>
      com.github.benmanes.caffeine.cache.Cache<K,​V>
      createCache​(int maximumSize, java.time.Duration duration, boolean recordStats)
      Create a cache with both size and time-based eviction policies
      static <K,​V>
      com.github.benmanes.caffeine.cache.Cache<K,​V>
      createCache​(java.time.Duration duration)
      Create a cache with a time-based eviction policy
      static <K,​V>
      com.github.benmanes.caffeine.cache.Cache<K,​V>
      createCache​(java.time.Duration duration, boolean recordStats)
      Create a cache with a time-based eviction policy
      static <K,​V>
      java.util.Map<K,​V>
      createCacheAsMap​(int maximumSize)
      Create a cache with a size-based eviction policy as a thread-safe map
      static <K,​V>
      java.util.Map<K,​V>
      createCacheAsMap​(int maximumSize, java.time.Duration duration)
      Create a cache with both size and time-based eviction policies as a thead-safe map
      static <K,​V>
      java.util.Map<K,​V>
      createCacheAsMap​(java.time.Duration duration)
      Create a cache with a time-based eviction policy as a thread-safe map
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • createCache

        public static <K,​V> com.github.benmanes.caffeine.cache.Cache<K,​V> createCache​(java.time.Duration duration)
        Create a cache with a time-based eviction policy
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        duration - the duration of entries after they are written to the cache
        Returns:
        the cache instance
      • createCache

        public static <K,​V> com.github.benmanes.caffeine.cache.Cache<K,​V> createCache​(java.time.Duration duration,
                                                                                                  boolean recordStats)
        Create a cache with a time-based eviction policy
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        duration - the duration of entries after they are written to the cache
        recordStats - specifies whether stats should be recorded for the cache
        Returns:
        the cache instance
      • createCache

        public static <K,​V> com.github.benmanes.caffeine.cache.Cache<K,​V> createCache​(int maximumSize)
        Create a cache with a size-based eviction policy
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        maximumSize - the maximum size of the cache before entries are evicted
        Returns:
        the cache instance
      • createCache

        public static <K,​V> com.github.benmanes.caffeine.cache.Cache<K,​V> createCache​(int maximumSize,
                                                                                                  boolean recordStats)
        Create a cache with a size-based eviction policy
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        maximumSize - the maximum size of the cache before entries are evicted
        recordStats - specifies whether stats should be recorded for the cache
        Returns:
        the cache instance
      • createCache

        public static <K,​V> com.github.benmanes.caffeine.cache.Cache<K,​V> createCache​(int maximumSize,
                                                                                                  java.time.Duration duration)
        Create a cache with both size and time-based eviction policies
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        maximumSize - the maximum size of the cache before entries are evicted
        duration - the duration of entries after they are written to the cache
        Returns:
        the cache instance
      • createCache

        public static <K,​V> com.github.benmanes.caffeine.cache.Cache<K,​V> createCache​(int maximumSize,
                                                                                                  java.time.Duration duration,
                                                                                                  boolean recordStats)
        Create a cache with both size and time-based eviction policies
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        maximumSize - the maximum size of the cache before entries are evicted
        duration - the duration of entries after they are written to the cache
        recordStats - specifies whether stats should be recorded for the cache
        Returns:
        the cache instance
      • createCacheAsMap

        public static <K,​V> java.util.Map<K,​V> createCacheAsMap​(java.time.Duration duration)
        Create a cache with a time-based eviction policy as a thread-safe map
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        duration - the duration of entries after they are written to the cache
        Returns:
        a thread-safe map view of entries in the cache instance
      • createCacheAsMap

        public static <K,​V> java.util.Map<K,​V> createCacheAsMap​(int maximumSize)
        Create a cache with a size-based eviction policy as a thread-safe map
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        maximumSize - the maximum size of the cache before entries are evicted
        Returns:
        a thread-safe map view of entries in the cache instance
      • createCacheAsMap

        public static <K,​V> java.util.Map<K,​V> createCacheAsMap​(int maximumSize,
                                                                            java.time.Duration duration)
        Create a cache with both size and time-based eviction policies as a thead-safe map
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        maximumSize - the maximum size of the cache before entries are evicted
        duration - the duration of entries after they are written to the cache
        Returns:
        a thread-safe map view of entries in the cache instance