public abstract class AbstractCacheMissAware<T> extends Object
Modifier and Type | Field and Description |
---|---|
protected javax.cache.CacheManager |
cacheManager |
protected StatisticsService |
statisticsService |
Constructor and Description |
---|
AbstractCacheMissAware() |
Modifier and Type | Method and Description |
---|---|
protected String |
buildKey(String... params)
Build the key representing this missed cache item.
|
protected void |
clearCache(String cacheName)
Remove all items from the underlying cache - a complete clear
|
protected javax.cache.Cache<String,T> |
getCache(String cacheName)
Retrieve the underlying cache for this query miss cache.
|
protected T |
getCachedObject(Class<T> responseClass,
String cacheName,
String statisticsName,
PersistentRetrieval<T> retrieval,
String... params)
This is the main entry point for retrieving an object from this cache.
|
protected abstract org.apache.commons.logging.Log |
getLogger()
To provide more accurate logging, this abstract cache should utilize a logger from its child
implementation.
|
protected T |
getNullObject(Class<T> responseClass)
Retrieve a null representation of the cache item.
|
protected T |
getObjectFromCache(String key,
String cacheName)
Retrieve the missed cache item from the specified cache.
|
protected void |
removeItemFromCache(String cacheName,
String... params)
Remove a specific cache item from the underlying cache
|
protected StatisticsService statisticsService
protected javax.cache.CacheManager cacheManager
protected String buildKey(String... params)
params
- the appropriate params comprising a unique key for this cache itemprotected T getObjectFromCache(String key, String cacheName)
T
- the type of the cache itemkey
- the unique key for the cache itemcacheName
- the name of the cache - this is the cache region name from ehcache configprotected javax.cache.Cache<String,T> getCache(String cacheName)
cacheName
- the name of the cache - the ehcache region nameprotected void removeItemFromCache(String cacheName, String... params)
cacheName
- the name of the cache - the ehcache region nameparams
- the appropriate params comprising a unique key for this cache itemprotected void clearCache(String cacheName)
cacheName
- the name of the cache - the ehcache region nameprotected T getNullObject(Class<T> responseClass)
T
- the type of the cache itemresponseClass
- the class representing the type of the cache itemprotected T getCachedObject(Class<T> responseClass, String cacheName, String statisticsName, PersistentRetrieval<T> retrieval, String... params)
T
- the type of the cache itemresponseClass
- the class representing the type of the cache itemcacheName
- the name of the cache - the ehcache region namestatisticsName
- the name to use for cache hit statisticsretrieval
- the block of code to execute if a cache miss is not found in this cacheparams
- the appropriate params comprising a unique key for this cache itemStatisticsService
protected abstract org.apache.commons.logging.Log getLogger()
Log
instance from the subclass of this abstract classCopyright © 2022. All rights reserved.