public abstract class AbstractCacheService extends Object implements ICacheService
getCache()
method which will be fulfilled according to the cache
implementation.Constructor and Description |
---|
AbstractCacheService() |
Modifier and Type | Method and Description |
---|---|
void |
clearCache(String cacheName)
Clear the contents of the specified cache.
|
<K,V> Set<K> |
getAllKeysFromCache(String cacheName)
Get all of the keys associated with the specified cache.
|
<K,V> Collection<V> |
getAllValuesFromCache(String cacheName)
Get all of the values associated with the specified cache.
|
abstract <K,V> ICache<K,V> |
getCache(String cacheName)
Get the named cache from the cache service.
|
<K,V> V |
getFromCache(String cacheName,
K key)
Get the value associated with the specified cache and key.
|
<K,V> void |
putInCache(String cacheName,
K key,
V value)
Add a new key-value pair to the specified cache.
|
<K,V> void |
putSafeInCache(String cacheName,
K key,
V value)
Add a new key-value pair to the specified cache, but only if there is no existing
entry associated with the specified key.
|
<K,V> void |
removeFromCache(String cacheName,
K key)
Remove the entry associated with the specified key from the specified cache.
|
int |
sizeOfCache(String cacheName)
Retrieve the size of the specified cache.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initialise, shutdown
public abstract <K,V> ICache<K,V> getCache(String cacheName)
ICacheService
getCache
in interface ICacheService
K
- The object type that acts as the key for the cacheV
- The value that is stored in the cachecacheName
- the name of the cache to retrievepublic <K,V> V getFromCache(String cacheName, K key)
ICacheService
getFromCache
in interface ICacheService
K
- The object type that acts as the key for the cacheV
- The value that is stored in the cachecacheName
- the name of the cache to look inkey
- the key of the entry to lookuppublic <K,V> void putInCache(String cacheName, K key, V value) throws CacheOperationException
ICacheService
putInCache
in interface ICacheService
K
- The object type that acts as the key for the cacheV
- The value that is stored in the cachecacheName
- the name of the cachekey
- the key to addvalue
- the value to addCacheOperationException
- if there is an error adding the new key-value pair to the cachepublic <K,V> void putSafeInCache(String cacheName, K key, V value) throws CacheOperationException
ICacheService
putSafeInCache
in interface ICacheService
K
- The object type that acts as the key for the cacheV
- The value that is stored in the cachecacheName
- the name of the cachekey
- the key to addvalue
- the value to addCacheOperationException
- if the specified key already exists in the cache with a non-null valuepublic <K,V> void removeFromCache(String cacheName, K key)
ICacheService
removeFromCache
in interface ICacheService
K
- The object type that acts as the key for the cacheV
- The value that is stored in the cachecacheName
- the name of the cache to look inkey
- the key of the entry to removepublic <K,V> Collection<V> getAllValuesFromCache(String cacheName)
ICacheService
getAllValuesFromCache
in interface ICacheService
K
- The object type that acts as the key for the cacheV
- The value that is stored in the cachecacheName
- the name of the cache to look inpublic <K,V> Set<K> getAllKeysFromCache(String cacheName)
ICacheService
getAllKeysFromCache
in interface ICacheService
K
- The object type that acts as the key for the cacheV
- The value that is stored in the cachecacheName
- the name of the cache to look inpublic int sizeOfCache(String cacheName)
ICacheService
sizeOfCache
in interface ICacheService
cacheName
- the name of the cachepublic void clearCache(String cacheName) throws CacheOperationException
ICacheService
clearCache
in interface ICacheService
cacheName
- the name of the cache to clearCacheOperationException
- if there was an error clearing the cacheCopyright © 2022. All rights reserved.