Class AbstractCacheableService
- java.lang.Object
-
- fr.paris.lutece.portal.service.cache.AbstractCacheableService
-
- All Implemented Interfaces:
CacheableService,LuteceService,Cloneable,net.sf.ehcache.event.CacheEventListener
- Direct Known Subclasses:
BaseUserPreferencesCacheService,ContentService,DatastoreCacheService,FileImagePublicService,LinksIncludeCacheService,LuteceUserCacheService,MailAttachmentCacheService,PageCacheService,PathCacheService,PortalMenuService,PortletCacheService,ResourceService,SiteMapCacheService
public abstract class AbstractCacheableService extends Object implements CacheableService, net.sf.ehcache.event.CacheEventListener
Base implementation for a cacheable service
-
-
Constructor Summary
Constructors Constructor Description AbstractCacheableService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()voiddispose()voidenableCache(boolean bEnable)Enable the cachenet.sf.ehcache.CachegetCache()Return a cache objectintgetCacheSize()Gets the number of item currently in the cache.ObjectgetFromCache(String strKey)Gets an object from the cacheStringgetInfos()Returns cache infosList<String>getKeys()Gets all keys in the cacheintgetMaxElements()Returns maximum elements accepted into the cachelonggetMemorySize()Return the memory sizeStringgetStatistics()Get cache statistics.longgetTimeToLive()Returns the time to live for objects in the cachevoidinitCache()Init the cache.voidinitCache(String strCacheName)Init the cache.booleanisCacheEnable()Gets the current cache status.voidnotifyElementEvicted(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)voidnotifyElementExpired(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)voidnotifyElementPut(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)voidnotifyElementRemoved(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)voidnotifyElementUpdated(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)voidnotifyRemoveAll(net.sf.ehcache.Ehcache ehch)voidputInCache(String strKey, Object object)Put an object into the cachevoidremoveKey(String strKey)Remove a key from the cachevoidresetCache()Reset the cache.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface fr.paris.lutece.portal.service.util.LuteceService
getName
-
-
-
-
Method Detail
-
initCache
public void initCache()
Init the cache. Should be called by the service at its initialization.
-
initCache
public void initCache(String strCacheName)
Init the cache. Should be called by the service at its initialization.- Parameters:
strCacheName- The cache name
-
putInCache
public void putInCache(String strKey, Object object)
Put an object into the cache- Parameters:
strKey- The key of the object to put into the cacheobject- The object to put into the cache
-
getFromCache
public Object getFromCache(String strKey)
Gets an object from the cache- 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- Returns:
- true if enable, otherwise false
-
enableCache
public void enableCache(boolean bEnable)
Enable the cache- Specified by:
enableCachein interfaceCacheableService- Parameters:
bEnable- true to enable, false to disable
-
resetCache
public void resetCache()
Reset the cache.- Specified by:
resetCachein interfaceCacheableService
-
getCacheSize
public int getCacheSize()
Gets the number of item currently in the cache.- Specified by:
getCacheSizein interfaceCacheableService- Returns:
- the number of item currently in the cache.
-
getCache
public net.sf.ehcache.Cache getCache()
Return a cache object- Returns:
- cache object
-
getKeys
public List<String> getKeys()
Gets all keys in the cache- Specified by:
getKeysin interfaceCacheableService- Returns:
- The List
-
getMaxElements
public int getMaxElements()
Returns maximum elements accepted into the cache- Specified by:
getMaxElementsin interfaceCacheableService- Returns:
- The max elements
-
getTimeToLive
public long getTimeToLive()
Returns the time to live for objects in the cache- Specified by:
getTimeToLivein interfaceCacheableService- Returns:
- The time to live in seconds
-
getMemorySize
public long getMemorySize()
Return the memory size- Specified by:
getMemorySizein interfaceCacheableService- Returns:
- the memory size
-
getInfos
public String getInfos()
Returns cache infos- Specified by:
getInfosin interfaceCacheableService- Returns:
- cache infos
-
getStatistics
public String getStatistics()
Get cache statistics. The string representation is susceptible to change- Returns:
- a string representation of cache statistics
- Since:
- 7.0.10
-
clone
public Object clone()
- Specified by:
clonein interfacenet.sf.ehcache.event.CacheEventListener- Returns:
- the instance
- See Also:
Object.clone()
-
notifyElementExpired
public void notifyElementExpired(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)- Specified by:
notifyElementExpiredin interfacenet.sf.ehcache.event.CacheEventListener
-
notifyElementRemoved
public void notifyElementRemoved(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)- Specified by:
notifyElementRemovedin interfacenet.sf.ehcache.event.CacheEventListener
-
notifyElementEvicted
public void notifyElementEvicted(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)- Specified by:
notifyElementEvictedin interfacenet.sf.ehcache.event.CacheEventListener
-
notifyRemoveAll
public void notifyRemoveAll(net.sf.ehcache.Ehcache ehch)
- Specified by:
notifyRemoveAllin interfacenet.sf.ehcache.event.CacheEventListener
-
notifyElementPut
public void notifyElementPut(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)- Specified by:
notifyElementPutin interfacenet.sf.ehcache.event.CacheEventListener
-
notifyElementUpdated
public void notifyElementUpdated(net.sf.ehcache.Ehcache ehch, net.sf.ehcache.Element elmnt)- Specified by:
notifyElementUpdatedin interfacenet.sf.ehcache.event.CacheEventListener
-
dispose
public void dispose()
- Specified by:
disposein interfacenet.sf.ehcache.event.CacheEventListener
-
removeKey
public void removeKey(String strKey)
Remove a key from the cache- Parameters:
strKey- The key to remove
-
-