public interface Cache
| Modifier and Type | Method and Description |
|---|---|
void |
addScope(String scope,
int maxItemsInMemory)
Adds a new scope to the cache.
|
void |
clearAll()
Clears the contents of the entire cache.
|
void |
clearScope(String scope)
Clears the contents of the specified scope in the cache.
|
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 list of scopes this cache manages.
|
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 in the cache.
|
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(String scope,
Object key,
Object value)
Puts an item in a scope.
|
void |
put(String scope,
Object key,
Object value,
long expireAfter,
long refreshFrequency,
CacheLoader loader,
Object... loaderParams)
Puts and 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.
|
boolean hasScope(String scope) throws InternalCacheEngineException
scope - the name of the scopeInternalCacheEngineException - if an error occurred in the underlying cache implementationCollection<String> getScopes() throws InternalCacheEngineException
InternalCacheEngineException - if an error occurred in the underlying cache implementationvoid addScope(String scope, int maxItemsInMemory) throws InternalCacheEngineException
scope - the name of the scopemaxItemsInMemory - the maximum number of items in memory, before they are evictedInternalCacheEngineException - if an error occurred in the underlying cache implementationvoid removeScope(String scope) throws InvalidScopeException, InternalCacheEngineException
scope - scope to removeInvalidScopeException - if the specified scope isn't a registered oneInternalCacheEngineException - if an error occurred in the underlying cache implementationint getSize(String scope) throws InvalidScopeException, InternalCacheEngineException
InvalidScopeException - if the specified scope isn't a registered oneInternalCacheEngineException - if an error occurred in the underlying cache implementationCollection<Object> getKeys(String scope) throws InvalidScopeException, InternalCacheEngineException
InvalidScopeException - if the specified scope isn't a registered oneInternalCacheEngineException - if an error occurred in the underlying cache implementationboolean hasKey(String scope, Object key) throws InvalidScopeException, InternalCacheEngineException
InvalidScopeException - if the specified scope isn't a registered oneInternalCacheEngineException - if an error occurred in the underlying cache implementationCacheItem get(String scope, Object key) throws InvalidScopeException, InternalCacheEngineException
scope - scope to get the item fromkey - unique key for the item within this scopeInvalidScopeException - if the specified scope isn't a registered oneInternalCacheEngineException - if an error occurred in the underlying cache implementationvoid put(String scope, Object key, Object value) throws InvalidScopeException, InternalCacheEngineException
scope - scope to add the item tokey - unique key for the item within this scopevalue - value to store in the cacheInvalidScopeException - if the specified scope isn't a registered oneInternalCacheEngineException - if an error occurred in the underlying cache implementationvoid put(String scope, Object key, Object value, long expireAfter, long refreshFrequency, CacheLoader loader, Object... loaderParams) throws InvalidScopeException, InternalCacheEngineException
scope - scope to add the item tokey - unique key for the item within this scopevalue - value to store in the cacheexpireAfter - the amount of time (in ticks, where the tick time span is defined at runtime) before
the item can be
removed from cache. Use CacheItem.NEVER_EXPIRE to indicate that there's no
expiration time.refreshFrequency - the amount of time (in ticks, where the tick time span is defined at runtime) before
items are reloaded
into the cache. Use CacheItem.NEVER_REFRESH to indicate that there's no need
for the item to
be refreshed. Note that when refreshing, there's almost always an old value for the
item in the cache
before the new value is loaded into the cache. The loader param is also
required in order for
the item to be refreshed.loader - the cache loader used to load a new value when the item needs to be refreshed. If not
specified and
the refreshFrequency is not CacheItem.NEVER_REFRESH,
the cache will use a default one.loaderParams - additional parameters the loader could needInvalidScopeException - if the specified scope isn't a registered oneInternalCacheEngineException - if an error occurred in the underlying cache implementationboolean remove(String scope, Object key) throws InvalidScopeException, InternalCacheEngineException
scope - scope to remove the item fromkey - unique key for the item within this scopeInvalidScopeException - if the specified scope isn't a registered oneInternalCacheEngineException - if an error occurred in the underlying cache implementationvoid clearAll()
throws InternalCacheEngineException
InternalCacheEngineException - if an error occurred in the underlying cache implementationvoid clearScope(String scope) throws InvalidScopeException, InternalCacheEngineException
scope - scope to clearInvalidScopeException - if the specified scope isn't a registered oneInternalCacheEngineException - if an error occurred in the underlying cache implementationCacheStatistics getStatistics(String scope)
scope - scope to inspectCopyright © 2018 CrafterCMS. All rights reserved.