Class CaffeineCache

java.lang.Object
org.springframework.cache.support.AbstractValueAdaptingCache
org.springframework.cache.caffeine.CaffeineCache
All Implemented Interfaces:
org.springframework.cache.Cache

public class CaffeineCache extends org.springframework.cache.support.AbstractValueAdaptingCache
Spring Cache adapter implementation on top of a Caffeine Cache instance.

Supports the retrieve(Object) and retrieve(Object, Supplier) operations through Caffeine's AsyncCache, when provided via the CaffeineCache(String, AsyncCache, boolean) constructor.

Requires Caffeine 3.0 or higher, as of Spring Framework 6.1.

Since:
4.3
Author:
Ben Manes, Juergen Hoeller, Stephane Nicoll
See Also:
  • Constructor Details

    • CaffeineCache

      public CaffeineCache(String name, com.github.benmanes.caffeine.cache.Cache<Object,Object> cache)
      Create a CaffeineCache instance with the specified name and the given internal Cache to use.
      Parameters:
      name - the name of the cache
      cache - the backing Caffeine Cache instance
    • CaffeineCache

      public CaffeineCache(String name, com.github.benmanes.caffeine.cache.Cache<Object,Object> cache, boolean allowNullValues)
      Create a CaffeineCache instance with the specified name and the given internal Cache to use.
      Parameters:
      name - the name of the cache
      cache - the backing Caffeine Cache instance
      allowNullValues - whether to accept and convert null values for this cache
    • CaffeineCache

      public CaffeineCache(String name, com.github.benmanes.caffeine.cache.AsyncCache<Object,Object> cache, boolean allowNullValues)
      Create a CaffeineCache instance with the specified name and the given internal AsyncCache to use.
      Parameters:
      name - the name of the cache
      cache - the backing Caffeine AsyncCache instance
      allowNullValues - whether to accept and convert null values for this cache
      Since:
      6.1
  • Method Details