Class RedisCacheManager


  • public class RedisCacheManager
    extends CacheManager
    Redis cache manager. Will store caches in Redis server. By default will connect to Redis running on local host.

    If redis server is located elsewhere, provide property files for different environments according to AppConfig rules. See: AppConfig for more information. The environment-specific properties files have to have the following properties for this class to function:

    • redis.cache.manager.host
    • redis.cache.manager.port

    If the properties or property files are missing, this class will default to localhost and default port for Redis.

    Limitation: Does not support CacheManager.flush(CacheEvent) with value 'ALL'.

    Author:
    Igor Polevoy on 12/7/15.
    • Constructor Detail

      • RedisCacheManager

        public RedisCacheManager()
    • Method Detail

      • getCache

        public Object getCache​(String group,
                               String key)
        Description copied from class: CacheManager
        Returns a cached item. Can return null if not found.
        Specified by:
        getCache in class CacheManager
        Parameters:
        group - group of caches - this is a name of a table for which query results are cached
        key - key of the item.
        Returns:
        a cached item. Can return null if not found.
      • addCache

        public void addCache​(String group,
                             String key,
                             Object cache)
        Description copied from class: CacheManager
        Adds item to cache.
        Specified by:
        addCache in class CacheManager
        Parameters:
        group - group name of cache.
        key - key of the item.
        cache - cache item to add to cache.
      • getImplementation

        public Object getImplementation()
        Description copied from class: CacheManager
        Returns underlying instance of implementation for specific configuration.
        Specified by:
        getImplementation in class CacheManager
        Returns:
        actual underlying implementation of cache. The same as configured in activejdbc.properties file. For instance: redis.clients.jedis.JedisPool.