public class RedisCache extends AbstractValueAdaptingCache
Cache
implementation using for Redis as underlying store.
Use RedisCacheManager
to create RedisCache
instances.RedisCacheConfiguration
,
RedisCacheWriter
Cache.ValueRetrievalException, Cache.ValueWrapper
Modifier | Constructor and Description |
---|---|
protected |
RedisCache(String name,
RedisCacheWriter cacheWriter,
RedisCacheConfiguration cacheConfig)
Create new
RedisCache . |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
protected String |
convertKey(Object key)
Convert
key to a String representation used for cache key creation. |
protected String |
createCacheKey(Object key)
Customization hook for creating cache key before it gets serialized.
|
protected Object |
deserializeCacheValue(byte[] value)
Deserialize the given value to the actual cache value.
|
void |
evict(Object key) |
<T> T |
get(Object key,
Callable<T> valueLoader) |
RedisCacheConfiguration |
getCacheConfiguration()
Get
RedisCacheConfiguration used. |
String |
getName() |
RedisCacheWriter |
getNativeCache() |
protected Object |
lookup(Object key) |
protected Object |
preProcessCacheValue(Object value)
Customization hook called before passing object to
RedisSerializer . |
void |
put(Object key,
Object value) |
Cache.ValueWrapper |
putIfAbsent(Object key,
Object value) |
protected byte[] |
serializeCacheKey(String cacheKey)
Serialize the key.
|
protected byte[] |
serializeCacheValue(Object value)
Serialize the value to cache.
|
fromStoreValue, get, get, isAllowNullValues, toStoreValue, toValueWrapper
protected RedisCache(String name, RedisCacheWriter cacheWriter, RedisCacheConfiguration cacheConfig)
RedisCache
.name
- must not be null.cacheWriter
- must not be null.cacheConfig
- must not be null.protected Object lookup(Object key)
lookup
in class AbstractValueAdaptingCache
public String getName()
public RedisCacheWriter getNativeCache()
public Cache.ValueWrapper putIfAbsent(Object key, Object value)
public void evict(Object key)
public void clear()
public RedisCacheConfiguration getCacheConfiguration()
RedisCacheConfiguration
used.RedisCacheConfiguration
. Never null.protected Object preProcessCacheValue(Object value)
RedisSerializer
.value
- can be null.protected byte[] serializeCacheKey(String cacheKey)
cacheKey
- must not be null.protected byte[] serializeCacheValue(Object value)
value
- must not be null.protected Object deserializeCacheValue(byte[] value)
value
- must not be null.protected String createCacheKey(Object key)
key
- will never be null.protected String convertKey(Object key)
key
to a String
representation used for cache key creation.key
- will never be null.IllegalStateException
- if key
cannot be converted to String
.Copyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.