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.
Constructor and Description |
---|
CaffeineCache(java.lang.String name,
com.github.benmanes.caffeine.cache.Cache<java.lang.Object,java.lang.Object> cache)
Create a
CaffeineCache instance with the specified name and the
given internal Cache to use. |
CaffeineCache(java.lang.String name,
com.github.benmanes.caffeine.cache.Cache<java.lang.Object,java.lang.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(java.lang.Object key) |
org.springframework.cache.Cache.ValueWrapper |
get(java.lang.Object key) |
<T> T |
get(java.lang.Object key,
java.util.concurrent.Callable<T> valueLoader) |
java.lang.String |
getName() |
com.github.benmanes.caffeine.cache.Cache<java.lang.Object,java.lang.Object> |
getNativeCache() |
protected java.lang.Object |
lookup(java.lang.Object key) |
void |
put(java.lang.Object key,
java.lang.Object value) |
org.springframework.cache.Cache.ValueWrapper |
putIfAbsent(java.lang.Object key,
java.lang.Object value) |
public CaffeineCache(java.lang.String name, com.github.benmanes.caffeine.cache.Cache<java.lang.Object,java.lang.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(java.lang.String name, com.github.benmanes.caffeine.cache.Cache<java.lang.Object,java.lang.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 java.lang.String getName()
public final com.github.benmanes.caffeine.cache.Cache<java.lang.Object,java.lang.Object> getNativeCache()
@Nullable public org.springframework.cache.Cache.ValueWrapper get(java.lang.Object key)
get
in interface org.springframework.cache.Cache
get
in class org.springframework.cache.support.AbstractValueAdaptingCache
@Nullable public <T> T get(java.lang.Object key, java.util.concurrent.Callable<T> valueLoader)
protected java.lang.Object lookup(java.lang.Object key)
lookup
in class org.springframework.cache.support.AbstractValueAdaptingCache
public void put(java.lang.Object key, @Nullable java.lang.Object value)
@Nullable public org.springframework.cache.Cache.ValueWrapper putIfAbsent(java.lang.Object key, @Nullable java.lang.Object value)
public void evict(java.lang.Object key)
public void clear()