Class AbstractCacheableService

    • Constructor Detail

      • AbstractCacheableService

        public AbstractCacheableService()
    • 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 cache
        object - 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:
        isCacheEnable in interface CacheableService
        Returns:
        true if enable, otherwise false
      • enableCache

        public void enableCache​(boolean bEnable)
        Enable the cache
        Specified by:
        enableCache in interface CacheableService
        Parameters:
        bEnable - true to enable, false to disable
      • getCacheSize

        public int getCacheSize()
        Gets the number of item currently in the cache.
        Specified by:
        getCacheSize in interface CacheableService
        Returns:
        the number of item currently in the cache.
      • getCache

        public net.sf.ehcache.Cache getCache()
        Return a cache object
        Returns:
        cache object
      • getMaxElements

        public int getMaxElements()
        Returns maximum elements accepted into the cache
        Specified by:
        getMaxElements in interface CacheableService
        Returns:
        The max elements
      • getTimeToLive

        public long getTimeToLive()
        Returns the time to live for objects in the cache
        Specified by:
        getTimeToLive in interface CacheableService
        Returns:
        The time to live in seconds
      • getMemorySize

        public long getMemorySize()
        Return the memory size
        Specified by:
        getMemorySize in interface CacheableService
        Returns:
        the memory size
      • 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:
        clone in interface net.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:
        notifyElementExpired in interface net.sf.ehcache.event.CacheEventListener
      • notifyElementRemoved

        public void notifyElementRemoved​(net.sf.ehcache.Ehcache ehch,
                                         net.sf.ehcache.Element elmnt)
        Specified by:
        notifyElementRemoved in interface net.sf.ehcache.event.CacheEventListener
      • notifyElementEvicted

        public void notifyElementEvicted​(net.sf.ehcache.Ehcache ehch,
                                         net.sf.ehcache.Element elmnt)
        Specified by:
        notifyElementEvicted in interface net.sf.ehcache.event.CacheEventListener
      • notifyRemoveAll

        public void notifyRemoveAll​(net.sf.ehcache.Ehcache ehch)
        Specified by:
        notifyRemoveAll in interface net.sf.ehcache.event.CacheEventListener
      • notifyElementPut

        public void notifyElementPut​(net.sf.ehcache.Ehcache ehch,
                                     net.sf.ehcache.Element elmnt)
        Specified by:
        notifyElementPut in interface net.sf.ehcache.event.CacheEventListener
      • notifyElementUpdated

        public void notifyElementUpdated​(net.sf.ehcache.Ehcache ehch,
                                         net.sf.ehcache.Element elmnt)
        Specified by:
        notifyElementUpdated in interface net.sf.ehcache.event.CacheEventListener
      • dispose

        public void dispose()
        Specified by:
        dispose in interface net.sf.ehcache.event.CacheEventListener
      • removeKey

        public void removeKey​(String strKey)
        Remove a key from the cache
        Parameters:
        strKey - The key to remove