public class CaffeineCache
extends org.springframework.cache.support.AbstractValueAdaptingCache
Cache
adapter implementation
on top of a Caffeine Cache
instance.
Requires Caffeine 2.1 or higher.
CaffeineCacheManager
Constructor and Description |
---|
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. |
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. |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
evict(Object key) |
boolean |
evictIfPresent(Object key) |
<T> T |
get(Object key,
Callable<T> valueLoader) |
String |
getName() |
com.github.benmanes.caffeine.cache.Cache<Object,Object> |
getNativeCache() |
boolean |
invalidate() |
protected Object |
lookup(Object key) |
void |
put(Object key,
Object value) |
org.springframework.cache.Cache.ValueWrapper |
putIfAbsent(Object key,
Object value) |
public CaffeineCache(String name, com.github.benmanes.caffeine.cache.Cache<Object,Object> cache)
CaffeineCache
instance with the specified name and the
given internal Cache
to use.name
- the name of the cachecache
- the backing Caffeine Cache instancepublic CaffeineCache(String name, com.github.benmanes.caffeine.cache.Cache<Object,Object> cache, boolean allowNullValues)
CaffeineCache
instance with the specified name and the
given internal Cache
to use.name
- the name of the cachecache
- the backing Caffeine Cache instanceallowNullValues
- whether to accept and convert null
values for this cachepublic final String getName()
public final com.github.benmanes.caffeine.cache.Cache<Object,Object> getNativeCache()
@Nullable protected Object lookup(Object key)
lookup
in class org.springframework.cache.support.AbstractValueAdaptingCache
@Nullable public org.springframework.cache.Cache.ValueWrapper putIfAbsent(Object key, @Nullable Object value)
public void evict(Object key)
public boolean evictIfPresent(Object key)
public void clear()
public boolean invalidate()