Class LFUEvictionStrategy

java.lang.Object
com.j_spaces.map.eviction.AbstractEvictionStrategy
com.j_spaces.map.eviction.LFUEvictionStrategy
All Implemented Interfaces:
EvictionStrategy

public class LFUEvictionStrategy extends AbstractEvictionStrategy
The heap LFUDA ( Least Frequently Used) policy keeps popular objects in cache regardless of their size and thus optimizes byte hit rate at the expense of hit rate since one large, popular object will prevent many smaller, slightly less popular objects from being cached.
Since:
5.0
Version:
1.0
Author:
Guy Korland
  • Constructor Details

    • LFUEvictionStrategy

      public LFUEvictionStrategy()
  • Method Details

    • clear

      public void clear()
      Clear EvictionStrategy internal structures only and doesn't clear cache.
    • discardEntry

      public void discardEntry(CacheEntry entry)
      Discard an Entry from the EvictionStrategy internal structures.
      Parameters:
      entry - the entry to discard from the eviction strategy internal structures
    • evict

      public int evict(Cache cache)
      Evicts batch of CacheEntry from the Cache according to the eviction strategy.
      Parameters:
      cache - the cache to be evicted
      Returns:
      the amount of entries evicted
    • touchEntry

      public void touchEntry(CacheEntry entry)
      Informs the eviction strategy on a CacheEntry use.
      Parameters:
      entry - the touched entry
    • createEntry

      public CacheEntry createEntry(Object key, Object value, long ttl, int version)
      Creates new CacheEntry for the Cache and probably saves the entry in the internal structures.
      Parameters:
      key - the entry key
      value - the entry value
      ttl - the time to keep the entry in cache
      version - the entry version
      Returns:
      a CacheEntry that holds all the parameters and probably saved in the eviction strategy internal structures