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.
Requires Caffeine 2.1 or higher.
- Since:
- 4.3
- Author:
- Ben Manes, Juergen Hoeller, Stephane Nicoll
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.cache.Cache
org.springframework.cache.Cache.ValueRetrievalException, org.springframework.cache.Cache.ValueWrapper -
Constructor Summary
ConstructorsConstructorDescriptionCaffeineCache(String name, com.github.benmanes.caffeine.cache.Cache<Object, Object> cache) Create aCaffeineCacheinstance with the specified name and the given internalCacheto use.CaffeineCache(String name, com.github.benmanes.caffeine.cache.Cache<Object, Object> cache, boolean allowNullValues) Create aCaffeineCacheinstance with the specified name and the given internalCacheto use. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidbooleanevictIfPresent(Object key) <T> Tfinal StringgetName()booleanprotected Objectvoidorg.springframework.cache.Cache.ValueWrapperputIfAbsent(Object key, Object value) Methods inherited from class org.springframework.cache.support.AbstractValueAdaptingCache
fromStoreValue, get, get, isAllowNullValues, toStoreValue, toValueWrapper
-
Constructor Details
-
CaffeineCache
Create aCaffeineCacheinstance with the specified name and the given internalCacheto use.- Parameters:
name- the name of the cachecache- the backing Caffeine Cache instance
-
CaffeineCache
public CaffeineCache(String name, com.github.benmanes.caffeine.cache.Cache<Object, Object> cache, boolean allowNullValues) Create aCaffeineCacheinstance with the specified name and the given internalCacheto use.- Parameters:
name- the name of the cachecache- the backing Caffeine Cache instanceallowNullValues- whether to accept and convertnullvalues for this cache
-
-
Method Details
-
getName
-
getNativeCache
-
get
-
lookup
- Specified by:
lookupin classorg.springframework.cache.support.AbstractValueAdaptingCache
-
put
-
putIfAbsent
-
evict
-
evictIfPresent
-
clear
public void clear() -
invalidate
public boolean invalidate()
-