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(java.lang.String name,
com.google.common.cache.Cache<java.lang.Object,java.lang.Object> cache)
Create a
GuavaCache instance with the specified name and the
given internal Cache to use. |
GuavaCache(java.lang.String name,
com.google.common.cache.Cache<java.lang.Object,java.lang.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(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.google.common.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 GuavaCache(java.lang.String name,
com.google.common.cache.Cache<java.lang.Object,java.lang.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(java.lang.String name,
com.google.common.cache.Cache<java.lang.Object,java.lang.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 java.lang.String getName()
public final com.google.common.cache.Cache<java.lang.Object,java.lang.Object> getNativeCache()
public org.springframework.cache.Cache.ValueWrapper get(java.lang.Object key)
get in interface org.springframework.cache.Cacheget in class org.springframework.cache.support.AbstractValueAdaptingCachepublic <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.AbstractValueAdaptingCachepublic void put(java.lang.Object key,
java.lang.Object value)
public org.springframework.cache.Cache.ValueWrapper putIfAbsent(java.lang.Object key,
java.lang.Object value)
public void evict(java.lang.Object key)
public void clear()