Class 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

public class CachingComponent<K,V> extends AbstractLogEnabled implements Initializable, Disposable
Simple memory cache with a thread clearing the cache every day.
  • Constructor Details

  • Method Details

    • initialize

      public void initialize() throws Exception
      Specified by:
      initialize in interface Initializable
      Throws:
      Exception
    • dispose

      public void dispose()
      Specified by:
      dispose in interface Disposable
    • getObjectFromCache

      protected V getObjectFromCache(K key)
      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

      protected void addObjectInCache(K key, V object)
      Adds a key/object pair in the cache.
      Parameters:
      key - the object's key.
      object - the object to be cached.
    • removeObjectFromCache

      protected void removeObjectFromCache(K key)
      Removes a key/object pair in the cache.
      Parameters:
      key - the object's key.
    • clearCache

      protected void clearCache()
      Removes all entries from the cache.
    • isCacheEnabled

      protected boolean isCacheEnabled()
      Returns true if the cache is enabled.
      Returns:
      true if the cache is enabled.