public class GuavaCache
extends java.lang.Object
implements org.springframework.cache.Cache
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. |
GuavaCache(java.lang.String name,
com.google.common.cache.Cache<java.lang.Object,java.lang.Object> cache,
boolean allowNullValues)
Create a
GuavaCache instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
evict(java.lang.Object key) |
protected java.lang.Object |
fromStoreValue(java.lang.Object storeValue)
Convert the given value from the internal store to a user value
returned from the get method (adapting
null). |
org.springframework.cache.Cache.ValueWrapper |
get(java.lang.Object key) |
<T> T |
get(java.lang.Object key,
java.lang.Class<T> type) |
java.lang.String |
getName() |
com.google.common.cache.Cache<java.lang.Object,java.lang.Object> |
getNativeCache() |
boolean |
isAllowNullValues() |
void |
put(java.lang.Object key,
java.lang.Object value) |
protected java.lang.Object |
toStoreValue(java.lang.Object userValue)
Convert the given user value, as passed into the put method,
to a value in the internal store (adapting
null). |
public GuavaCache(java.lang.String name,
com.google.common.cache.Cache<java.lang.Object,java.lang.Object> cache)
GuavaCache instance.name - the name of the cachecache - 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.name - the name of the cachecache - backing Guava Cache instanceallowNullValues - whether to accept and convert null values for this cachepublic final java.lang.String getName()
getName in interface org.springframework.cache.Cachepublic final com.google.common.cache.Cache<java.lang.Object,java.lang.Object> getNativeCache()
getNativeCache in interface org.springframework.cache.Cachepublic final boolean isAllowNullValues()
public org.springframework.cache.Cache.ValueWrapper get(java.lang.Object key)
get in interface org.springframework.cache.Cachepublic <T> T get(java.lang.Object key,
java.lang.Class<T> type)
get in interface org.springframework.cache.Cachepublic void put(java.lang.Object key,
java.lang.Object value)
put in interface org.springframework.cache.Cachepublic void evict(java.lang.Object key)
evict in interface org.springframework.cache.Cachepublic void clear()
clear in interface org.springframework.cache.Cacheprotected java.lang.Object fromStoreValue(java.lang.Object storeValue)
null).storeValue - the store valueprotected java.lang.Object toStoreValue(java.lang.Object userValue)
null).userValue - the given user value