org.springframework.data.redis.cache
Class RedisCacheManager

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

public class RedisCacheManager
extends Object
implements org.springframework.cache.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
 org.springframework.cache.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 org.springframework.cache.Cache getCache(String name)
Specified by:
getCache in interface org.springframework.cache.CacheManager

getCacheNames

public Collection<String> getCacheNames()
Specified by:
getCacheNames in interface org.springframework.cache.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