Class CacheManager

java.lang.Object
org.javalite.activejdbc.cache.CacheManager
Direct Known Subclasses:
EHCache3Manager, EHCacheManager, NopeCacheManager, RedisCacheManager

public abstract class CacheManager extends Object
Abstract method to be sub-classed by various caching technologies.
Author:
Igor Polevoy
  • Constructor Details

    • CacheManager

      public CacheManager()
  • Method Details

    • getCache

      public abstract Object getCache(String group, String key)
      Returns a cached item. Can return null if not found.
      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 abstract void addCache(String group, String key, Object cache)
      Adds item to cache.
      Parameters:
      group - group name of cache.
      key - key of the item.
      cache - cache item to add to cache.
    • doFlush

      public abstract void doFlush(CacheEvent event)
    • flush

      public final void flush(CacheEvent event, boolean propagate)
      Flashes cache.
      Parameters:
      propagate - true to propagate event to listeners, false to not propagate
      event - type of caches to flush.
    • flush

      public final void flush(CacheEvent event)
      Flashes cache.
      Parameters:
      event - type of caches to flush.
    • addCacheEventListener

      public final void addCacheEventListener(CacheEventListener listener)
    • removeCacheEventListener

      public final void removeCacheEventListener(CacheEventListener listener)
    • removeAllCacheEventListeners

      public final void removeAllCacheEventListeners()
    • purgeTableCache

      public void purgeTableCache(MetaModel metaModel)
      This method purges (removes) all caches associated with a table, if caching is enabled and a corresponding model is marked cached.
      Parameters:
      metaModel - meta-model whose caches are to purge.
    • purgeTableCache

      public void purgeTableCache(String tableName)
      Use purgeTableCache(MetaModel) whenever you can.
      Parameters:
      tableName - name of table whose caches to purge.
    • getKey

      public String getKey(String tableName, String query, Object[] params)
      Generates a cache key. Subclasses may override this implementation.
      Parameters:
      tableName - name of a table
      query - query
      params - query parameters.
      Returns:
      generated key for tied to these parameters.
    • getImplementation

      public abstract Object getImplementation()
      Returns underlying instance of implementation for specific configuration.
      Returns:
      actual underlying implementation of cache. The same as configured in activejdbc.properties file. For instance: redis.clients.jedis.JedisPool.