public abstract class Cache extends Object
Constructor and Description |
---|
Cache() |
Modifier and Type | Method and Description |
---|---|
<K extends CacheKey,T extends Serializable> |
get(K key,
AccessRestrictedCacheElementProvider<K,T> provider)
This method checks the access for the given item, before it returns it.
|
<K extends CacheKey,T extends Serializable> |
get(K key,
CacheElementProvider<K,T> provider)
Retrieves an element identified by the provided key from the cache.
|
protected abstract CacheElementWrapper<Serializable> |
handleGet(String cacheKey)
Retrieves an element identified by the provided key from the cache.
|
protected abstract void |
handleInvalidate(String cacheKey)
Invalidates the data stored under the supplied key.
|
protected abstract void |
handlePut(String cacheKey,
CacheElementWrapper<Serializable> cacheElement,
int timeToLive)
Stores an element under the key cacheKey in the cache.
|
<K extends CacheKey,T extends Serializable> |
invalidate(K key,
CacheElementProvider<K,T> provider)
Invalidates a cached element that has the key cacheKey.
|
void |
invalidateAll(CacheElementProvider<?,?> provider)
Invalidate all cached items that were retrieved from the given provider.
|
void |
invalidateAllOfCurrentClient(CacheElementProvider<?,?> provider)
Invalidate all cached items that were retrieved from the given provider.
|
<K extends CacheKey,T extends Serializable> |
put(K key,
CacheElementProvider<K,T> provider,
T data)
Stores some data in the cache under the provided key.
|
public <K extends CacheKey,T extends Serializable> T get(K key, AccessRestrictedCacheElementProvider<K,T> provider) throws AuthorizationException
K
- the type of the keyT
- the type of the cached elementkey
- the key to useprovider
- The provider for asserting access and loading the requested element in case it is
not cached.AuthorizationException
- Thrown, if the user has no access to the given item.public <K extends CacheKey,T extends Serializable> T get(K key, CacheElementProvider<K,T> provider)
K
- the type of the keyT
- the type of the cached elementkey
- the key to useprovider
- the provider for loading the requested element in case it is not cachedprotected abstract CacheElementWrapper<Serializable> handleGet(String cacheKey) throws CacheException
cacheKey
- the key used for storing the element in the cacheCacheException
- when there are problems with the backendprotected abstract void handleInvalidate(String cacheKey) throws CacheException
cacheKey
- the key used for cachingCacheException
- when the invalidation failedprotected abstract void handlePut(String cacheKey, CacheElementWrapper<Serializable> cacheElement, int timeToLive) throws CacheException
cacheKey
- the key used for caching and retrievingcacheElement
- the element to be cached; never nulltimeToLive
- the time in seconds until the item will expire. A negative value indicates eternal
caching.CacheException
- when caching failedpublic <K extends CacheKey,T extends Serializable> void invalidate(K key, CacheElementProvider<K,T> provider) throws CacheException
K
- the type of the keyT
- the type of the cached elementkey
- the key to useprovider
- the associated providerCacheException
- when the invalidation failedpublic void invalidateAll(CacheElementProvider<?,?> provider)
provider
- the provider from which the cached items to be invalidated were loadedpublic void invalidateAllOfCurrentClient(CacheElementProvider<?,?> provider)
provider
- the provider from which the cached items to be invalidated were loadedpublic <K extends CacheKey,T extends Serializable> void put(K key, CacheElementProvider<K,T> provider, T data) throws CacheException
K
- the type of the keyT
- the type of the data to be cachedkey
- the key to useprovider
- the associated providerdata
- the data to be cached; can be nullCacheException
- when caching failedCopyright © 2019 Communote team. All rights reserved.