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
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Adds item to cache.void
addCacheEventListener(CacheEventListener listener)
abstract void
doFlush(CacheEvent event)
void
flush(CacheEvent event)
Flashes cache.void
flush(CacheEvent event, boolean propagate)
Flashes cache.abstract Object
Returns a cached item.abstract Object
Returns underlying instance of implementation for specific configuration.Generates a cache key.void
purgeTableCache(String tableName)
UsepurgeTableCache(MetaModel)
whenever you can.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.void
void
removeCacheEventListener(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.properties
file. For instance:redis.clients.jedis.JedisPool
.
-