Class AbstractCacheableService<K,V>
java.lang.Object
fr.paris.lutece.portal.service.cache.AbstractCacheableService<K,V>
- Type Parameters:
K- the type of keys maintained by the cacheV- the type of cached values
- All Implemented Interfaces:
CacheableService<K,,V> Lutece107Cache<K,,V> LuteceService,Closeable,Serializable,AutoCloseable,Iterable<javax.cache.Cache.Entry<K,,V>> javax.cache.Cache<K,V>
- Direct Known Subclasses:
BaseUserPreferencesCacheService,Default107Cache,LinksIncludeCacheService,LuteceUserCacheService,PageCacheService,PathCacheService,PortletCacheService,ResourceService
Base Lutece implementation of the Cache using JCache (JSR-107) and cacheable service.
This class implements the JCache (JSR-107) cache API and provides the service for enabling and disabling caches
from an administration interface.
- See Also:
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidclose()booleancontainsKey(K key) voidderegisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) voidenableCache(boolean bEnable) Enables or disables the cache.getAndRemove(K key) getAndReplace(K key, V value) getCache()Return a cache object.javax.cache.CacheManagerintGets the number of items currently in the cache.getConfiguration(Class<C> clazz) getFromCache(K strKey) Deprecated.getInfos()Returns cache information.getKeys()Gets all keys in the cache.voidInit & create the cache.voidInit & create the cache.voidInit & create the cache.<T> TinvokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K, V, T> entryProcessor, Object... arguments) booleanGets the current cache status.booleanisClosed()booleanCan the cache be reset by automatic caches resetsbooleanCan the cache be emptied: a cache whose entries cannot be rebuilt on a cache miss is never reset, neither by a global reset nor by its own reset.booleanIs the cache required by the webapp: it holds data that are not read again elsewhere (the loaded plugins, a notification shared by the instances...).iterator()voidloadAll(Set<? extends K> keys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener) voidvoidbooleanputIfAbsent(K key, V value) voidputInCache(K strKey, V object) Deprecated.voidregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) booleanbooleanvoidvoidvoidDeprecated.booleanbooleanvoidResets the cache.voidSet cache.<T> TMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.cache.Cache
getNameMethods inherited from interface fr.paris.lutece.portal.service.cache.CacheableService
getMaxElements, getMemorySize, getTimeToLiveMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface fr.paris.lutece.portal.service.util.LuteceService
getName
-
Constructor Details
-
AbstractCacheableService
public AbstractCacheableService()
-
-
Method Details
-
initCache
public void initCache()Init & create the cache. Should be called by the class (cache) that extends AbstractCacheableService during its initialization. -
initCache
Init & create the cache. Should be called by the class (cache) that extends AbstractCacheableService during its initialization.- Parameters:
strCacheName- The cache name
-
initCache
Init & create the cache. Should be called by the class (cache) that extends AbstractCacheableService during its initialization.- Parameters:
strCacheName- The cache namebEnable- enable cache
-
putInCache
Deprecated.Put an object into the cache. This method will be removed in the next version. Useput(K, V)instead.- Parameters:
strKey- The key of the object to put into the cacheobject- The object to put into the cache
-
getFromCache
Deprecated.Gets an object from the cache. This method will be removed in the next version. Useget(K)instead.- Parameters:
strKey- The key of the object to retrieve from the cache- Returns:
- The object from the cache
-
isCacheEnable
public boolean isCacheEnable()Gets the current cache status.- Specified by:
isCacheEnablein interfaceCacheableService<K,V> - Returns:
- true if the cache is enabled, otherwise false
-
getCacheSize
public int getCacheSize()Gets the number of items currently in the cache.- Specified by:
getCacheSizein interfaceCacheableService<K,V> - Returns:
- the number of items currently in the cache
-
enableCache
public void enableCache(boolean bEnable) Enables or disables the cache.- Specified by:
enableCachein interfaceCacheableService<K,V> - Parameters:
bEnable- true to enable, false to disable
-
resetCache
public void resetCache()Resets the cache.- Specified by:
resetCachein interfaceCacheableService<K,V>
-
getKeys
Gets all keys in the cache.- Specified by:
getKeysin interfaceCacheableService<K,V> - Returns:
- a list of all keys in the cache
-
getInfos
Returns cache information.- Specified by:
getInfosin interfaceCacheableService<K,V> - Returns:
- cache information
-
removeKey
Deprecated.Remove a key from the cache. This method will be removed in the next version. Useremove(K)instead.- Parameters:
strKey- The key to remove
-
get
-
getAll
-
containsKey
-
loadAll
-
put
-
getAndPut
-
putAll
-
putIfAbsent
-
remove
-
remove
-
getAndRemove
-
replace
-
replace
-
getAndReplace
-
removeAll
-
removeAll
public void removeAll() -
clear
public void clear() -
getConfiguration
-
invoke
-
invokeAll
-
getCacheManager
public javax.cache.CacheManager getCacheManager() -
close
public void close() -
isClosed
public boolean isClosed() -
unwrap
-
registerCacheEntryListener
-
deregisterCacheEntryListener
-
iterator
-
setCache
Set cache.- Parameters:
cache- the cache to set
-
getCache
Return a cache object.- Returns:
- cache object
-
isPreventGlobalReset
public boolean isPreventGlobalReset()Description copied from interface:CacheableServiceCan the cache be reset by automatic caches resets- Specified by:
isPreventGlobalResetin interfaceCacheableService<K,V> - Returns:
- true is the cache can be reset by automatic / massive caches resets, false otherwise
-
isRequired
public boolean isRequired()Is the cache required by the webapp: it holds data that are not read again elsewhere (the loaded plugins, a notification shared by the instances...). A required cache is always enabled, whatever the status saved in the database or chosen in the back office.- Specified by:
isRequiredin interfaceCacheableService<K,V> - Returns:
- true if the cache can never be disabled
-
isPreventReset
public boolean isPreventReset()Can the cache be emptied: a cache whose entries cannot be rebuilt on a cache miss is never reset, neither by a global reset nor by its own reset.- Specified by:
isPreventResetin interfaceCacheableService<K,V> - Returns:
- true if the cache can never be reset
-