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
Direct Known Subclasses:
RedissonSpringCacheNativeManager

public class RedissonSpringCacheManager extends Object implements org.springframework.cache.CacheManager, org.springframework.context.ResourceLoaderAware, org.springframework.beans.factory.InitializingBean
A CacheManager implementation backed by Redisson instance.
Author:
Nikita Koksharov
  • Constructor Details

    • 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 - object
      config - 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 - object
      config - object
      codec - 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 - object
      configLocation - 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 - object
      configLocation - path
      codec - object
  • Method Details

    • setAllowNullValues

      public void setAllowNullValues(boolean allowNullValues)
      Defines possibility of storing null values.

      Default is true

      Parameters:
      allowNullValues - stores if true
    • setTransactionAware

      public void setTransactionAware(boolean transactionAware)
      Defines if cache aware of Spring-managed transactions. If true put/evict operations are executed only for successful transaction in after-commit phase.

      Default is false

      Parameters:
      transactionAware - cache is transaction aware if true
    • 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 interface org.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 interface org.springframework.cache.CacheManager
    • setResourceLoader

      public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
      Specified by:
      setResourceLoader in interface org.springframework.context.ResourceLoaderAware
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception