Package org.ametys.core.util
Class CachingComponent<K,V>
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.util.CachingComponent<K,V>
- Type Parameters:
K- the type of keys for caching objects by this component.V- the type of objects cached by this component.
- All Implemented Interfaces:
LogEnabled,Disposable,Initializable
Simple memory cache with a thread clearing the cache every day.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddObjectInCache(K key, V object) Adds a key/object pair in the cache.protected voidRemoves all entries from the cache.voiddispose()protected VgetObjectFromCache(K key) Returns an object from the cache, correspondong to the specified key, or null if none.voidprotected booleanReturns true if the cache is enabled.protected voidremoveObjectFromCache(K key) Removes a key/object pair in the cache.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Constructor Details
-
CachingComponent
public CachingComponent()
-
-
Method Details
-
initialize
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
dispose
- Specified by:
disposein interfaceDisposable
-
getObjectFromCache
Returns an object from the cache, correspondong to the specified key, or null if none.- Parameters:
key- the object's key.- Returns:
- the object from cache.
-
addObjectInCache
Adds a key/object pair in the cache.- Parameters:
key- the object's key.object- the object to be cached.
-
removeObjectFromCache
Removes a key/object pair in the cache.- Parameters:
key- the object's key.
-
clearCache
Removes all entries from the cache. -
isCacheEnabled
Returns true if the cache is enabled.- Returns:
- true if the cache is enabled.
-