Package org.javalite.activejdbc.cache
Class CacheManager
java.lang.Object
org.javalite.activejdbc.cache.CacheManager
- Direct Known Subclasses:
EHCache3Manager,EHCacheManager,NopeCacheManager,RedisCacheManager
Abstract method to be sub-classed by various caching technologies.
- Author:
- Igor Polevoy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidAdds item to cache.voidaddCacheEventListener(CacheEventListener listener)abstract voiddoFlush(CacheEvent event)voidflush(CacheEvent event)Flashes cache.voidflush(CacheEvent event, boolean propagate)Flashes cache.abstract ObjectReturns a cached item.abstract ObjectReturns underlying instance of implementation for specific configuration.Generates a cache key.voidpurgeTableCache(String tableName)UsepurgeTableCache(MetaModel)whenever you can.voidpurgeTableCache(MetaModel metaModel)This method purges (removes) all caches associated with a table, if caching is enabled and a corresponding model is marked cached.voidvoidremoveCacheEventListener(CacheEventListener listener)
-
Constructor Details
-
CacheManager
public CacheManager()
-
-
Method Details
-
getCache
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 cachedkey- key of the item.- Returns:
- a cached item. Can return null if not found.
-
addCache
Adds item to cache.- Parameters:
group- group name of cache.key- key of the item.cache- cache item to add to cache.
-
doFlush
-
flush
Flashes cache.- Parameters:
propagate- true to propagate event to listeners, false to not propagateevent- type of caches to flush.
-
flush
Flashes cache.- Parameters:
event- type of caches to flush.
-
addCacheEventListener
-
removeCacheEventListener
-
removeAllCacheEventListeners
public final void removeAllCacheEventListeners() -
purgeTableCache
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
UsepurgeTableCache(MetaModel)whenever you can.- Parameters:
tableName- name of table whose caches to purge.
-
getKey
Generates a cache key. Subclasses may override this implementation.- Parameters:
tableName- name of a tablequery- queryparams- query parameters.- Returns:
- generated key for tied to these parameters.
-
getImplementation
Returns underlying instance of implementation for specific configuration.- Returns:
- actual underlying implementation of cache. The same as configured in
activejdbc.propertiesfile. For instance:redis.clients.jedis.JedisPool.
-