Package org.craftercms.core.service.impl
Class CacheServiceImpl
java.lang.Object
org.craftercms.core.service.impl.CacheServiceImpl
- All Implemented Interfaces:
CacheService
Default implementation of
CacheService
. Adapts a Cache
.- Author:
- Sumer Jabri, Alfonso Vásquez
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new scope to the cache for the given context.void
clearAll()
Clears the contents of the entire cache.void
clearScope
(Context context) Clears the contents of the scope of the given context.Retrieves an item's value from the scope of the given context, or null if not found.Retrieves an item from the scope of the given context, or null if not found.Collection<?>
Returns a list of the keys of the items present in the scope of the given context.Returns the list of scopes this cache manages.int
Returns the quantity of items present in scope of the given context.getStatistics
(Context context) Returns the statistics for the scope of the given context.boolean
Returns true if there's and item with the specified key in the scope of the given context.boolean
Returns true if the scope of the given context exists.void
Puts an item in the scope of the given context.void
put
(Context context, Object key, Object value, CachingOptions cachingOptions, CacheLoader loader, Object... loaderParams) Puts and item in the scope of the given context.boolean
Removes an item from the scope of the given context.void
removeScope
(Context context) Removes the scope associated to the given contextvoid
Sets the cache engine.
-
Field Details
-
cache
-
-
Constructor Details
-
CacheServiceImpl
public CacheServiceImpl()
-
-
Method Details
-
setCache
Sets the cache engine.- Parameters:
cache
-
-
getScopes
Description copied from interface:CacheService
Returns the list of scopes this cache manages.- Specified by:
getScopes
in interfaceCacheService
- Throws:
InternalCacheEngineException
-
clearAll
Description copied from interface:CacheService
Clears the contents of the entire cache.- Specified by:
clearAll
in interfaceCacheService
- Throws:
InternalCacheEngineException
-
addScope
Description copied from interface:CacheService
Adds a new scope to the cache for the given context.- Specified by:
addScope
in interfaceCacheService
- Throws:
InternalCacheEngineException
-
removeScope
public void removeScope(Context context) throws InvalidContextException, InternalCacheEngineException Description copied from interface:CacheService
Removes the scope associated to the given context- Specified by:
removeScope
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
hasScope
public boolean hasScope(Context context) throws InvalidContextException, InternalCacheEngineException Description copied from interface:CacheService
Returns true if the scope of the given context exists.- Specified by:
hasScope
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
getSize
Description copied from interface:CacheService
Returns the quantity of items present in scope of the given context.- Specified by:
getSize
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
getKeys
public Collection<?> getKeys(Context context) throws InvalidContextException, InternalCacheEngineException Description copied from interface:CacheService
Returns a list of the keys of the items present in the scope of the given context.- Specified by:
getKeys
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
hasKey
public boolean hasKey(Context context, Object key) throws InvalidContextException, InternalCacheEngineException Description copied from interface:CacheService
Returns true if there's and item with the specified key in the scope of the given context.- Specified by:
hasKey
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
getItem
public CacheItem getItem(Context context, Object key) throws InvalidContextException, InternalCacheEngineException Description copied from interface:CacheService
Retrieves an item from the scope of the given context, or null if not found.- Specified by:
getItem
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
get
public Object get(Context context, Object key) throws InvalidContextException, InternalCacheEngineException Description copied from interface:CacheService
Retrieves an item's value from the scope of the given context, or null if not found.- Specified by:
get
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
put
public void put(Context context, Object key, Object value) throws InvalidContextException, InternalCacheEngineException Description copied from interface:CacheService
Puts an item in the scope of the given context.- Specified by:
put
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
put
public void put(Context context, Object key, Object value, CachingOptions cachingOptions, CacheLoader loader, Object... loaderParams) throws InvalidContextException, InternalCacheEngineException Description copied from interface:CacheService
Puts and item in the scope of the given context.- Specified by:
put
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
remove
public boolean remove(Context context, Object key) throws InvalidContextException, InternalCacheEngineException Description copied from interface:CacheService
Removes an item from the scope of the given context.- Specified by:
remove
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
clearScope
public void clearScope(Context context) throws InvalidContextException, InternalCacheEngineException Description copied from interface:CacheService
Clears the contents of the scope of the given context.- Specified by:
clearScope
in interfaceCacheService
- Throws:
InvalidContextException
InternalCacheEngineException
-
getStatistics
Description copied from interface:CacheService
Returns the statistics for the scope of the given context.- Specified by:
getStatistics
in interfaceCacheService
-