public class EhCacheStoreAdapter extends Object implements CacheStoreAdapter
CacheStoreAdapter using an underlying EhCache CacheManager.| Modifier and Type | Field and Description |
|---|---|
static String |
SCOPE_MANAGER_NAME |
| Constructor and Description |
|---|
EhCacheStoreAdapter()
Default no-args constructor.
|
EhCacheStoreAdapter(List<net.sf.ehcache.config.CacheConfiguration> scopeConfigs)
Constructor that receives a list of scope configurations.
|
| 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.
|
void |
destroy()
Destroy method, called by the Spring container.
|
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 static final String SCOPE_MANAGER_NAME
public EhCacheStoreAdapter()
scopeManager by calling the factory method
CacheManager.newInstance(net.sf.ehcache.config.Configuration), because we want a
separate CacheManager, not the singleton one, since we don't want to the tick() method of a cache
implementation to be called on a CacheManager that doesn't have CacheItems.public EhCacheStoreAdapter(List<net.sf.ehcache.config.CacheConfiguration> scopeConfigs)
@PreDestroy public void destroy()
CacheManager.shutdown().public boolean hasScope(String scope) throws Exception
CacheStoreAdapterhasScope in interface CacheStoreAdapterExceptionpublic Collection<String> getScopes() throws Exception
getScopes in interface CacheStoreAdapterExceptionpublic void addScope(String scope, int maxItemsInMemory) throws Exception
Cache.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.