Package org.redisson.spring.cache
Class RedissonSpringCacheManager
- java.lang.Object
-
- org.redisson.spring.cache.RedissonSpringCacheManager
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.cache.CacheManager
,org.springframework.context.ResourceLoaderAware
public class RedissonSpringCacheManager extends Object implements org.springframework.cache.CacheManager, org.springframework.context.ResourceLoaderAware, org.springframework.beans.factory.InitializingBean
ACacheManager
implementation backed by Redisson instance.- Author:
- Nikita Koksharov
-
-
Constructor Summary
Constructors Constructor Description RedissonSpringCacheManager(RedissonClient redisson)
Creates CacheManager supplied by Redisson instanceRedissonSpringCacheManager(RedissonClient redisson, String configLocation)
Creates CacheManager supplied by Redisson instance and Cache config mapped by Cache name.RedissonSpringCacheManager(RedissonClient redisson, String configLocation, Codec codec)
Creates CacheManager supplied by Redisson instance, Codec instance and Config location path.RedissonSpringCacheManager(RedissonClient redisson, Map<String,? extends CacheConfig> config)
Creates CacheManager supplied by Redisson instance and Cache config mapped by Cache nameRedissonSpringCacheManager(RedissonClient redisson, Map<String,? extends CacheConfig> config, Codec codec)
Creates CacheManager supplied by Redisson instance, Codec instance and Cache config mapped by Cache name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
protected CacheConfig
createDefaultConfig()
org.springframework.cache.Cache
getCache(String name)
Collection<String>
getCacheNames()
protected RMap<Object,Object>
getMap(String name, CacheConfig config)
protected RMapCache<Object,Object>
getMapCache(String name, CacheConfig config)
void
setAllowNullValues(boolean allowNullValues)
Defines possibility of storingnull
values.void
setCacheNames(Collection<String> names)
Defines 'fixed' cache names.void
setCodec(Codec codec)
Set Codec instance shared between all Cache instancesvoid
setConfig(Map<String,? extends CacheConfig> config)
Set cache config mapped by cache namevoid
setConfigLocation(String configLocation)
Set cache config locationvoid
setRedisson(RedissonClient redisson)
Set Redisson instancevoid
setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
-
-
-
Constructor Detail
-
RedissonSpringCacheManager
public RedissonSpringCacheManager(RedissonClient redisson)
Creates CacheManager supplied by Redisson instance- Parameters:
redisson
- object
-
RedissonSpringCacheManager
public RedissonSpringCacheManager(RedissonClient redisson, Map<String,? extends CacheConfig> config)
Creates CacheManager supplied by Redisson instance and Cache config mapped by Cache name- Parameters:
redisson
- objectconfig
- object
-
RedissonSpringCacheManager
public RedissonSpringCacheManager(RedissonClient redisson, Map<String,? extends CacheConfig> config, Codec codec)
Creates CacheManager supplied by Redisson instance, Codec instance and Cache config mapped by Cache name.Each Cache instance share one Codec instance.
- Parameters:
redisson
- objectconfig
- objectcodec
- object
-
RedissonSpringCacheManager
public RedissonSpringCacheManager(RedissonClient redisson, String configLocation)
Creates CacheManager supplied by Redisson instance and Cache config mapped by Cache name.Loads the config file from the class path, interpreting plain paths as class path resource names that include the package path (e.g. "mypackage/myresource.txt").
- Parameters:
redisson
- objectconfigLocation
- path
-
RedissonSpringCacheManager
public RedissonSpringCacheManager(RedissonClient redisson, String configLocation, Codec codec)
Creates CacheManager supplied by Redisson instance, Codec instance and Config location path.Each Cache instance share one Codec instance.
Loads the config file from the class path, interpreting plain paths as class path resource names that include the package path (e.g. "mypackage/myresource.txt").
- Parameters:
redisson
- objectconfigLocation
- pathcodec
- object
-
-
Method Detail
-
setAllowNullValues
public void setAllowNullValues(boolean allowNullValues)
Defines possibility of storingnull
values.Default is
true
- Parameters:
allowNullValues
- - stores iftrue
-
setCacheNames
public void setCacheNames(Collection<String> names)
Defines 'fixed' cache names. A new cache instance will not be created in dynamic for non-defined names.`null` parameter setups dynamic mode
- Parameters:
names
- of caches
-
setConfigLocation
public void setConfigLocation(String configLocation)
Set cache config location- Parameters:
configLocation
- object
-
setConfig
public void setConfig(Map<String,? extends CacheConfig> config)
Set cache config mapped by cache name- Parameters:
config
- object
-
setRedisson
public void setRedisson(RedissonClient redisson)
Set Redisson instance- Parameters:
redisson
- instance
-
setCodec
public void setCodec(Codec codec)
Set Codec instance shared between all Cache instances- Parameters:
codec
- object
-
createDefaultConfig
protected CacheConfig createDefaultConfig()
-
getCache
public org.springframework.cache.Cache getCache(String name)
- Specified by:
getCache
in interfaceorg.springframework.cache.CacheManager
-
getMap
protected RMap<Object,Object> getMap(String name, CacheConfig config)
-
getMapCache
protected RMapCache<Object,Object> getMapCache(String name, CacheConfig config)
-
getCacheNames
public Collection<String> getCacheNames()
- Specified by:
getCacheNames
in interfaceorg.springframework.cache.CacheManager
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
- Specified by:
setResourceLoader
in interfaceorg.springframework.context.ResourceLoaderAware
-
-