Package org.craftercms.core.cache.impl
Interface CacheStoreAdapter
-
- All Known Implementing Classes:
GuavaCacheStoreAdapter
,MapCacheStoreAdapter
,NoopCacheStoreAdapter
public interface CacheStoreAdapter
Adapter to the real data structure used to store the items of a cache.- Author:
- Sumer Jabri, Alfonso Vásquez
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addScope(String scope, int maxItemsInMemory)
Adds a new scope to the underlying store.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.
-
-
-
Method Detail
-
hasScope
boolean hasScope(String scope) throws Exception
Returns true if the specified scope exists in the cache.- Throws:
Exception
-
getScopes
Collection<String> getScopes() throws Exception
Returns the scopes managed by the underlying store.- Throws:
Exception
-
addScope
void addScope(String scope, int maxItemsInMemory) throws Exception
Adds a new scope to the underlying store.- Parameters:
scope
- the name of the scopemaxItemsInMemory
- the maximum number of items in memory, before they are evicted- Throws:
Exception
-
removeScope
void removeScope(String scope) throws Exception
Removes an existing scope and all the items that are in it.- Parameters:
scope
- scope to remove- Throws:
Exception
-
getSize
int getSize(String scope) throws Exception
Returns the quantity of items present in the specified scope.- Returns:
- the size of the scope (quantity of items)
- Throws:
Exception
-
getKeys
Collection<Object> getKeys(String scope) throws Exception
Returns a list of the keys of the items present in the specified scope.- Returns:
- a list of the keys of the available items in the scope
- Throws:
Exception
-
hasKey
boolean hasKey(String scope, Object key) throws Exception
Returns true if there's and item with the specified key in the specified scope.- Returns:
- true if the key exists in the scope, false otherwise
- Throws:
Exception
-
get
CacheItem get(String scope, Object key) throws Exception
Retrieves an item from a scope.- Parameters:
scope
- scope to get the item fromkey
- unique key for the item within this scope- Returns:
- the requested item if found, null otherwise
- Throws:
Exception
-
put
void put(CacheItem item) throws Exception
Puts an item in a scope. The scope is obtained throughCacheItem.getScope()
.- Parameters:
item
- the item to put- Throws:
Exception
-
remove
boolean remove(String scope, Object key) throws Exception
Removes an item from a scope.- Parameters:
scope
- scope to remove the item fromkey
- unique key for the item within this scope- Returns:
- true if the removal was successful, false otherwise
- Throws:
Exception
-
clearAll
void clearAll() throws Exception
Clears the contents of the entire store.- Throws:
Exception
-
clearScope
void clearScope(String scope) throws Exception
Clears the contents of the specified scope in the underlying store.- Parameters:
scope
- scope to clear- Throws:
Exception
-
getStatistics
CacheStatistics getStatistics(String scope)
Returns the statistics of the specified scope from the underlying store.- Parameters:
scope
- scope to inspect- Returns:
- the statistics
-
-