public class GuavaCache
extends org.springframework.cache.support.AbstractValueAdaptingCache
Cache
adapter implementation
on top of a Guava Cache
instance.
Requires Google Guava 12.0 or higher.
Constructor and Description |
---|
GuavaCache(String name,
com.google.common.cache.Cache<Object,Object> cache)
Create a
GuavaCache instance with the specified name and the
given internal Cache to use. |
GuavaCache(String name,
com.google.common.cache.Cache<Object,Object> cache,
boolean allowNullValues)
Create a
GuavaCache instance with the specified name and the
given internal Cache to use. |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
evict(Object key) |
org.springframework.cache.Cache.ValueWrapper |
get(Object key) |
<T> T |
get(Object key,
Callable<T> valueLoader) |
String |
getName() |
com.google.common.cache.Cache<Object,Object> |
getNativeCache() |
protected Object |
lookup(Object key) |
void |
put(Object key,
Object value) |
org.springframework.cache.Cache.ValueWrapper |
putIfAbsent(Object key,
Object value) |
public GuavaCache(String name, com.google.common.cache.Cache<Object,Object> cache)
GuavaCache
instance with the specified name and the
given internal Cache
to use.name
- the name of the cachecache
- the backing Guava Cache instancepublic GuavaCache(String name, com.google.common.cache.Cache<Object,Object> cache, boolean allowNullValues)
GuavaCache
instance with the specified name and the
given internal Cache
to use.name
- the name of the cachecache
- the backing Guava Cache instanceallowNullValues
- whether to accept and convert null
values for this cachepublic final String getName()
public org.springframework.cache.Cache.ValueWrapper get(Object key)
get
in interface org.springframework.cache.Cache
get
in class org.springframework.cache.support.AbstractValueAdaptingCache
protected Object lookup(Object key)
lookup
in class org.springframework.cache.support.AbstractValueAdaptingCache
public org.springframework.cache.Cache.ValueWrapper putIfAbsent(Object key, Object value)
public void evict(Object key)
public void clear()