public class MapCacheStoreAdapter extends Object implements CacheStoreAdapter
CacheStoreAdapter using an underlying Map.| Constructor and Description |
|---|
MapCacheStoreAdapter()
Default constructor.
|
MapCacheStoreAdapter(List<String> scopes)
Constructor that receives a list of scopes that need to created.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addScope(String scope,
int maxItemsInMemory)
Adds a new scope.
|
void |
clearAll()
Clears the contents of the entire store.
|
void |
clearScope(String scope)
Clears the contents of the specified scope in the underlying store.
|
CacheItem |
get(String scope,
Object key)
Retrieves an item from a scope.
|
Collection<Object> |
getKeys(String scope)
Returns a list of the keys of the items present in the specified scope.
|
Collection<String> |
getScopes()
Returns the scopes managed by the underlying store.
|
int |
getSize(String scope)
Returns the quantity of items present in the specified scope.
|
CacheStatistics |
getStatistics(String scope)
Returns the statistics of the specified scope from the underlying store.
|
boolean |
hasKey(String scope,
Object key)
Returns true if there's and item with the specified key in the specified scope.
|
boolean |
hasScope(String scope)
Returns true if the specified scope exists in the cache.
|
void |
put(CacheItem item)
Puts an item in a scope.
|
boolean |
remove(String scope,
Object key)
Removes an item from a scope.
|
void |
removeScope(String scope)
Removes an existing scope and all the items that are in it.
|
public MapCacheStoreAdapter()
scopeCaches as a ConcurrentHashMappublic MapCacheStoreAdapter(List<String> scopes)
ConcurrentHashMap.public boolean hasScope(String scope) throws Exception
hasScope in interface CacheStoreAdapterExceptionpublic Collection<String> getScopes() throws Exception
getScopes in interface CacheStoreAdapterExceptionpublic void addScope(String scope, int maxItemsInMemory) throws Exception
ConcurrentHashMap.addScope in interface CacheStoreAdapterscope - the name of the scopemaxItemsInMemory - the maximum number of items in memory, before they are evictedExceptionpublic void removeScope(String scope) throws Exception
removeScope in interface CacheStoreAdapterscope - scope to removeExceptionpublic int getSize(String scope) throws Exception
getSize in interface CacheStoreAdapterExceptionpublic Collection<Object> getKeys(String scope) throws Exception
getKeys in interface CacheStoreAdapterExceptionpublic boolean hasKey(String scope, Object key) throws Exception
hasKey in interface CacheStoreAdapterExceptionpublic CacheItem get(String scope, Object key) throws Exception
get in interface CacheStoreAdapterscope - scope to get the item fromkey - unique key for the item within this scopeExceptionpublic void put(CacheItem item) throws Exception
CacheItem.getScope().put in interface CacheStoreAdapteritem - the item to putExceptionpublic boolean remove(String scope, Object key) throws Exception
remove in interface CacheStoreAdapterscope - scope to remove the item fromkey - unique key for the item within this scopeExceptionpublic void clearAll()
throws Exception
clearAll in interface CacheStoreAdapterExceptionpublic void clearScope(String scope) throws Exception
clearScope in interface CacheStoreAdapterscope - scope to clearExceptionpublic CacheStatistics getStatistics(String scope)
getStatistics in interface CacheStoreAdapterscope - scope to inspectCopyright © 2018 CrafterCMS. All rights reserved.