Class NoopCacheStoreAdapter
- java.lang.Object
-
- org.craftercms.core.cache.impl.store.NoopCacheStoreAdapter
-
- All Implemented Interfaces:
CacheStoreAdapter
public class NoopCacheStoreAdapter extends Object implements CacheStoreAdapter
Implementation of aCacheStoreAdapter
that uses no data structure and whose operations do nothing. Useful in scenarios where you need a cache reference but don't need to cache anything or it's not appropriate, and when testing or troubleshooting.- Author:
- Sumer Jabri, Alfonso Vásquez
-
-
Constructor Summary
Constructors Constructor Description NoopCacheStoreAdapter()
-
Method Summary
All Methods Instance Methods Concrete 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
public boolean hasScope(String scope) throws Exception
Description copied from interface:CacheStoreAdapter
Returns true if the specified scope exists in the cache.- Specified by:
hasScope
in interfaceCacheStoreAdapter
- Throws:
Exception
-
getScopes
public Collection<String> getScopes()
Description copied from interface:CacheStoreAdapter
Returns the scopes managed by the underlying store.- Specified by:
getScopes
in interfaceCacheStoreAdapter
-
addScope
public void addScope(String scope, int maxItemsInMemory)
Description copied from interface:CacheStoreAdapter
Adds a new scope to the underlying store.- Specified by:
addScope
in interfaceCacheStoreAdapter
- Parameters:
scope
- the name of the scopemaxItemsInMemory
- the maximum number of items in memory, before they are evicted
-
removeScope
public void removeScope(String scope)
Description copied from interface:CacheStoreAdapter
Removes an existing scope and all the items that are in it.- Specified by:
removeScope
in interfaceCacheStoreAdapter
- Parameters:
scope
- scope to remove
-
getSize
public int getSize(String scope)
Description copied from interface:CacheStoreAdapter
Returns the quantity of items present in the specified scope.- Specified by:
getSize
in interfaceCacheStoreAdapter
- Returns:
- the size of the scope (quantity of items)
-
getKeys
public Collection<Object> getKeys(String scope)
Description copied from interface:CacheStoreAdapter
Returns a list of the keys of the items present in the specified scope.- Specified by:
getKeys
in interfaceCacheStoreAdapter
- Returns:
- a list of the keys of the available items in the scope
-
hasKey
public boolean hasKey(String scope, Object key)
Description copied from interface:CacheStoreAdapter
Returns true if there's and item with the specified key in the specified scope.- Specified by:
hasKey
in interfaceCacheStoreAdapter
- Returns:
- true if the key exists in the scope, false otherwise
-
get
public CacheItem get(String scope, Object key)
Description copied from interface:CacheStoreAdapter
Retrieves an item from a scope.- Specified by:
get
in interfaceCacheStoreAdapter
- Parameters:
scope
- scope to get the item fromkey
- unique key for the item within this scope- Returns:
- the requested item if found, null otherwise
-
put
public void put(CacheItem item)
Description copied from interface:CacheStoreAdapter
Puts an item in a scope. The scope is obtained throughCacheItem.getScope()
.- Specified by:
put
in interfaceCacheStoreAdapter
- Parameters:
item
- the item to put
-
remove
public boolean remove(String scope, Object key)
Description copied from interface:CacheStoreAdapter
Removes an item from a scope.- Specified by:
remove
in interfaceCacheStoreAdapter
- 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
-
clearAll
public void clearAll()
Description copied from interface:CacheStoreAdapter
Clears the contents of the entire store.- Specified by:
clearAll
in interfaceCacheStoreAdapter
-
clearScope
public void clearScope(String scope)
Description copied from interface:CacheStoreAdapter
Clears the contents of the specified scope in the underlying store.- Specified by:
clearScope
in interfaceCacheStoreAdapter
- Parameters:
scope
- scope to clear
-
getStatistics
public CacheStatistics getStatistics(String scope)
Description copied from interface:CacheStoreAdapter
Returns the statistics of the specified scope from the underlying store.- Specified by:
getStatistics
in interfaceCacheStoreAdapter
- Parameters:
scope
- scope to inspect- Returns:
- the statistics
-
-