org.springframework.data.redis.cache
Class RedisCacheManager

java.lang.Object
  extended by org.springframework.data.redis.cache.RedisCacheManager
All Implemented Interfaces:
CacheManager

public class RedisCacheManager
extends Object
implements CacheManager

CacheManager implementation for Redis. By default saves the keys directly, without appending a prefix (which acts as a namespace). To avoid clashes, it is recommended to change this (by setting 'usePrefix' to 'true'). For performance reasons, the current implementation uses a set for the keys in each cache.


Constructor Summary
RedisCacheManager(RedisTemplate template)
           
 
Method Summary
 Cache getCache(String name)
           
 Collection<String> getCacheNames()
           
 void setCachePrefix(RedisCachePrefix cachePrefix)
          Sets the cachePrefix.
 void setDefaultExpiration(long defaultExpireTime)
          Sets the default expire time (in seconds).
 void setExpires(Map<String,Long> expires)
          Sets the expire time (in seconds) for cache regions (by key).
 void setUsePrefix(boolean usePrefix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RedisCacheManager

public RedisCacheManager(RedisTemplate template)
Method Detail

getCache

public Cache getCache(String name)
Specified by:
getCache in interface CacheManager

getCacheNames

public Collection<String> getCacheNames()
Specified by:
getCacheNames in interface CacheManager

setUsePrefix

public void setUsePrefix(boolean usePrefix)

setCachePrefix

public void setCachePrefix(RedisCachePrefix cachePrefix)
Sets the cachePrefix. Defaults to 'DefaultRedisCachePrefix').

Parameters:
cachePrefix - the cachePrefix to set

setDefaultExpiration

public void setDefaultExpiration(long defaultExpireTime)
Sets the default expire time (in seconds).

Parameters:
defaultExpireTime - time in seconds.

setExpires

public void setExpires(Map<String,Long> expires)
Sets the expire time (in seconds) for cache regions (by key).

Parameters:
expires - time in seconds