Class BoundedMultiLruCache

All Implemented Interfaces:
Cache

public class BoundedMultiLruCache extends MultiLruCache
MultiLruCache -- in-memory bounded LRU cache with multiple LRU lists Underlying Hashtable is made into logical segments, with each segment having its own LRU list.
  • Field Details

    • maxSize

      protected long maxSize
    • currentSize

      protected long currentSize
  • Constructor Details

    • BoundedMultiLruCache

      public BoundedMultiLruCache()
  • Method Details

    • init

      public void init(int maxCapacity, Properties props) throws Exception
      initialize the LRU cache
      Specified by:
      init in interface Cache
      Overrides:
      init in class MultiLruCache
      Parameters:
      maxCapacity - maximum number of entries this cache may hold
      props - opaque list of properties for a given cache implementation
      Throws:
      Exception
    • itemAdded

      protected BaseCache.CacheItem itemAdded(BaseCache.CacheItem item)
      this item is just added to the cache
      Overrides:
      itemAdded in class MultiLruCache
      Parameters:
      item - CacheItem that was created
      Returns:
      a overflow item; may be null Cache bucket is already synchronized by the caller
    • itemRefreshed

      protected void itemRefreshed(BaseCache.CacheItem item, int oldSize)
      item value has been refreshed
      Overrides:
      itemRefreshed in class MultiLruCache
      Parameters:
      item - CacheItem that was refreshed
      oldSize - size of the previous value that was refreshed Cache bucket is already synchronized by the caller
    • itemRemoved

      protected void itemRemoved(BaseCache.CacheItem item)
      item value has been removed from the cache
      Overrides:
      itemRemoved in class MultiLruCache
      Parameters:
      item - CacheItem that was just removed Cache bucket is already synchronized by the caller
    • isThresholdReached

      protected boolean isThresholdReached()
      has cache reached its threshold
      Overrides:
      isThresholdReached in class BaseCache
      Returns:
      true when the cache reached its threshold
    • incrementCurrentSize

      protected final void incrementCurrentSize(int size)
      synchronized counter updates
    • decrementCurrentSize

      protected final void decrementCurrentSize(int size)
    • getStatByName

      public Object getStatByName(String key)
      get the desired statistic counter
      Specified by:
      getStatByName in interface Cache
      Overrides:
      getStatByName in class MultiLruCache
      Parameters:
      key - to corresponding stat
      Returns:
      an Object corresponding to the stat See also: Constant.java for the key
    • getStats

      public Map getStats()
      Description copied from class: MultiLruCache
      get the stats snapshot
      Specified by:
      getStats in interface Cache
      Overrides:
      getStats in class MultiLruCache
      Returns:
      a Map of stats See also: Constant.java for the keys