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
ConstructorDescriptionCaffeineCache
(String name, com.github.benmanes.caffeine.cache.Cache<Object, Object> cache) Create aCaffeineCache
instance with the specified name and the given internalCache
to use.CaffeineCache
(String name, com.github.benmanes.caffeine.cache.Cache<Object, Object> cache, boolean allowNullValues) Create aCaffeineCache
instance with the specified name and the given internalCache
to use. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
void
boolean
evictIfPresent
(Object key) <T> T
final String
getName()
boolean
protected Object
void
org.springframework.cache.Cache.ValueWrapper
putIfAbsent
(Object key, Object value) Methods inherited from class org.springframework.cache.support.AbstractValueAdaptingCache
fromStoreValue, get, get, isAllowNullValues, toStoreValue, toValueWrapper
-
Constructor Details
-
CaffeineCache
Create aCaffeineCache
instance with the specified name and the given internalCache
to 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 aCaffeineCache
instance with the specified name and the given internalCache
to use.- Parameters:
name
- the name of the cachecache
- the backing Caffeine Cache instanceallowNullValues
- whether to accept and convertnull
values for this cache
-
-
Method Details
-
getName
-
getNativeCache
-
get
-
lookup
- Specified by:
lookup
in classorg.springframework.cache.support.AbstractValueAdaptingCache
-
put
-
putIfAbsent
-
evict
-
evictIfPresent
-
clear
public void clear() -
invalidate
public boolean invalidate()
-