Package com.gentlyweb.utils
Interface MultipleObjectCacheManager
-
public interface MultipleObjectCacheManagerThis interface should be implemented by classes that contain X number of publicly available ObjectCaches, it provides methods that allow applications to control the caches without understanding what is inside the cache.
All of the methods in this interface are optional and if not supported then implementing classes should throwUnsupportedOperationException.
This interface mirrorsObjectCacheManagerbut each method (where appropriate) takes a key object to tell the implementing class which cache it wants the operation to occur on.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intcapacity(Object key)Return the current capacity of the cache, it should basically be (max size - current size).voidflush(Object key)Let the object cache be flushed.booleanisEmpty(Object key)Return whether the cache is empty or not.voidmerge(Object key, ObjectCache cache)Merge the current cache with another.voidputAll(Object key, Map map)Add all the entries in the Map to cache.voidresize(Object key, int size)Resize the cache to a particular size, if the size is actually bigger than the current size then this operation should not touch the cached objects, if the size is less then the cache should be reduced in size using the current policy until the size is reached.voidsetMaxSize(Object key, int size)Set the maximum size of the cache.voidsetPolicy(Object key, int policy)Set the policy for managing the cache, should be one of:ObjectCache.OLDEST,ObjectCache.YOUNGEST,ObjectCache.RANDOM.voidtoMap(Object object, Map map)Get all the entries in the cache as a Map of key to value.
-
-
-
Method Detail
-
flush
void flush(Object key)
Let the object cache be flushed.- Parameters:
key- The key to identify the particular cache.
-
setMaxSize
void setMaxSize(Object key, int size)
Set the maximum size of the cache.- Parameters:
key- The key to identify the particular cache.size- The maximum size.
-
resize
void resize(Object key, int size)
Resize the cache to a particular size, if the size is actually bigger than the current size then this operation should not touch the cached objects, if the size is less then the cache should be reduced in size using the current policy until the size is reached. Either way the maximum size should be set to this value.- Parameters:
key- The key to identify the particular cache.size- The new size.
-
capacity
int capacity(Object key)
Return the current capacity of the cache, it should basically be (max size - current size).- Parameters:
key- The key to identify the particular cache.- Returns:
- The current number of items that can be added until the cache reaches it's maximum size.
-
isEmpty
boolean isEmpty(Object key)
Return whether the cache is empty or not.- Parameters:
key- The key to identify the particular cache.- Returns:
trueif the cache is empty,falseif it has entries.
-
toMap
void toMap(Object object, Map map)
Get all the entries in the cache as a Map of key to value.- Parameters:
key- The key to identify the particular cache.map- The Map that should be populated with the key/values in the cache.
-
merge
void merge(Object key, ObjectCache cache)
Merge the current cache with another.- Parameters:
key- The key to identify the particular cache.cache- The cache to merge.
-
putAll
void putAll(Object key, Map map)
Add all the entries in the Map to cache.- Parameters:
key- The key to identify the particular cache.map- The Map to get key/values from.
-
setPolicy
void setPolicy(Object key, int policy)
Set the policy for managing the cache, should be one of:ObjectCache.OLDEST,ObjectCache.YOUNGEST,ObjectCache.RANDOM.- Parameters:
key- The key to identify the particular cache.policy- The policy.
-
-