public class RedisCache extends AbstractValueAdaptingCache
Cache.ValueRetrievalException, Cache.ValueWrapper
Constructor and Description |
---|
RedisCache(String name,
byte[] prefix,
RedisOperations<? extends Object,? extends Object> redisOperations,
long expiration)
Constructs a new
RedisCache instance. |
RedisCache(String name,
byte[] prefix,
RedisOperations<? extends Object,? extends Object> redisOperations,
long expiration,
boolean allowNullValues)
Constructs a new
RedisCache instance. |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
evict(Object key) |
void |
evict(RedisCacheElement element) |
protected Object |
fromStoreValue(Object storeValue) |
Cache.ValueWrapper |
get(Object key) |
<T> T |
get(Object key,
Callable<T> valueLoader) |
<T> T |
get(Object key,
Class<T> type)
Return the value to which this cache maps the specified key, generically specifying a type that return value will
be cast to.
|
RedisCacheElement |
get(RedisCacheKey cacheKey)
Return the value to which this cache maps the specified key.
|
String |
getName() |
Object |
getNativeCache()
This implementation simply returns the RedisTemplate used for configuring the cache, giving access to
the underlying Redis store.
|
protected Object |
lookup(Object key) |
void |
put(Object key,
Object value) |
void |
put(RedisCacheElement element)
Add the element by adding
SimpleValueWrapper.get() at RedisCacheElement.getKeyBytes() . |
Cache.ValueWrapper |
putIfAbsent(Object key,
Object value) |
Cache.ValueWrapper |
putIfAbsent(RedisCacheElement element)
Add the element as long as no element exists at
RedisCacheElement.getKeyBytes() . |
isAllowNullValues, toStoreValue, toValueWrapper
public RedisCache(String name, byte[] prefix, RedisOperations<? extends Object,? extends Object> redisOperations, long expiration)
RedisCache
instance.name
- cache nameprefix
- redisOperations
- expiration
- public RedisCache(String name, byte[] prefix, RedisOperations<? extends Object,? extends Object> redisOperations, long expiration, boolean allowNullValues)
RedisCache
instance.name
- cache nameprefix
- must not be null or empty.redisOperations
- expiration
- allowNullValues
- public <T> T get(Object key, Class<T> type)
get
in interface Cache
get
in class AbstractValueAdaptingCache
key
- type
- DATAREDIS-243
public Cache.ValueWrapper get(Object key)
get
in interface Cache
get
in class AbstractValueAdaptingCache
public RedisCacheElement get(RedisCacheKey cacheKey)
cacheKey
- the key whose associated value is to be returned via its binary representation.RedisCacheElement
stored at given key or null if no value found for key.protected Object fromStoreValue(Object storeValue)
fromStoreValue
in class AbstractValueAdaptingCache
public void put(RedisCacheElement element)
SimpleValueWrapper.get()
at RedisCacheElement.getKeyBytes()
. If the cache
previously contained a mapping for this RedisCacheElement.getKeyBytes()
, the old value is replaced by
SimpleValueWrapper.get()
.element
- must not be null.public Cache.ValueWrapper putIfAbsent(Object key, Object value)
public Cache.ValueWrapper putIfAbsent(RedisCacheElement element)
RedisCacheElement.getKeyBytes()
. If a value is present for
RedisCacheElement.getKeyBytes()
this one is returned.element
- must not be null.public void evict(Object key)
public void evict(RedisCacheElement element)
element
- RedisCacheElement.getKeyBytes()
public void clear()
public String getName()
public Object getNativeCache()
protected Object lookup(Object key)
lookup
in class AbstractValueAdaptingCache
Copyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.