Package org.craftercms.core.service.impl
Class CacheServiceImpl
- java.lang.Object
-
- org.craftercms.core.service.impl.CacheServiceImpl
-
- All Implemented Interfaces:
CacheService
public class CacheServiceImpl extends Object implements CacheService
Default implementation ofCacheService. Adapts aCache.- Author:
- Sumer Jabri, Alfonso Vásquez
-
-
Constructor Summary
Constructors Constructor Description CacheServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddScope(Context context)Adds a new scope to the cache for the given context.voidclearAll()Clears the contents of the entire cache.voidclearScope(Context context)Clears the contents of the scope of the given context.Objectget(Context context, Object key)Retrieves an item's value from the scope of the given context, or null if not found.CacheItemgetItem(Context context, Object key)Retrieves an item from the scope of the given context, or null if not found.Collection<?>getKeys(Context context)Returns a list of the keys of the items present in the scope of the given context.Collection<String>getScopes()Returns the list of scopes this cache manages.intgetSize(Context context)Returns the quantity of items present in scope of the given context.CacheStatisticsgetStatistics(Context context)Returns the statistics for the scope of the given context.booleanhasKey(Context context, Object key)Returns true if there's and item with the specified key in the scope of the given context.booleanhasScope(Context context)Returns true if the scope of the given context exists.voidput(Context context, Object key, Object value)Puts an item in the scope of the given context.voidput(Context context, Object key, Object value, CachingOptions cachingOptions, CacheLoader loader, Object... loaderParams)Puts and item in the scope of the given context.booleanremove(Context context, Object key)Removes an item from the scope of the given context.voidremoveScope(Context context)Removes the scope associated to the given contextvoidsetCache(Cache cache)Sets the cache engine.
-
-
-
Field Detail
-
cache
protected Cache cache
-
-
Method Detail
-
setCache
public void setCache(Cache cache)
Sets the cache engine.- Parameters:
cache-
-
getScopes
public Collection<String> getScopes() throws InternalCacheEngineException
Description copied from interface:CacheServiceReturns the list of scopes this cache manages.- Specified by:
getScopesin interfaceCacheService- Throws:
InternalCacheEngineException
-
clearAll
public void clearAll() throws InternalCacheEngineExceptionDescription copied from interface:CacheServiceClears the contents of the entire cache.- Specified by:
clearAllin interfaceCacheService- Throws:
InternalCacheEngineException
-
addScope
public void addScope(Context context) throws InternalCacheEngineException
Description copied from interface:CacheServiceAdds a new scope to the cache for the given context.- Specified by:
addScopein interfaceCacheService- Throws:
InternalCacheEngineException
-
removeScope
public void removeScope(Context context) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServiceRemoves the scope associated to the given context- Specified by:
removeScopein interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
hasScope
public boolean hasScope(Context context) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServiceReturns true if the scope of the given context exists.- Specified by:
hasScopein interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
getSize
public int getSize(Context context) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServiceReturns the quantity of items present in scope of the given context.- Specified by:
getSizein interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
getKeys
public Collection<?> getKeys(Context context) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServiceReturns a list of the keys of the items present in the scope of the given context.- Specified by:
getKeysin interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
hasKey
public boolean hasKey(Context context, Object key) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServiceReturns true if there's and item with the specified key in the scope of the given context.- Specified by:
hasKeyin interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
getItem
public CacheItem getItem(Context context, Object key) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServiceRetrieves an item from the scope of the given context, or null if not found.- Specified by:
getItemin interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
get
public Object get(Context context, Object key) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServiceRetrieves an item's value from the scope of the given context, or null if not found.- Specified by:
getin interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
put
public void put(Context context, Object key, Object value) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServicePuts an item in the scope of the given context.- Specified by:
putin interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
put
public void put(Context context, Object key, Object value, CachingOptions cachingOptions, CacheLoader loader, Object... loaderParams) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServicePuts and item in the scope of the given context.- Specified by:
putin interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
remove
public boolean remove(Context context, Object key) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServiceRemoves an item from the scope of the given context.- Specified by:
removein interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
clearScope
public void clearScope(Context context) throws InvalidContextException, InternalCacheEngineException
Description copied from interface:CacheServiceClears the contents of the scope of the given context.- Specified by:
clearScopein interfaceCacheService- Throws:
InvalidContextExceptionInternalCacheEngineException
-
getStatistics
public CacheStatistics getStatistics(Context context)
Description copied from interface:CacheServiceReturns the statistics for the scope of the given context.- Specified by:
getStatisticsin interfaceCacheService
-
-