Class ClockProPlusEviction

  • All Implemented Interfaces:
    Eviction

    public class ClockProPlusEviction
    extends AbstractEviction
    Eviction algorithm inspired from CLOCK Pro with 3 clocks.

    Uses a static allocation for hot and cold space sizes. No online or dynamic optimization is done yet. However, the hit rate for all measured access traces is better then LRU and it is resistant to scans.

    From cache2k version 1.2 to version 1.4 the implementation was simplefied and the demotion of hot entries removed. The result achieves similar or better hitrates.

    The Clock-Pro algorithm is explained by the authors in CLOCK-Pro: An Effective Improvement of the CLOCK Replacement and Clock-Pro: An Effective Replacement in OS Kernel.

    Author:
    Jens Wilke
    • Constructor Detail

    • Method Detail

      • getHotMax

        public long getHotMax()
      • getGhostMax

        public long getGhostMax()
      • updateHotMax

        protected void updateHotMax()
        Updates hot max based on current size. This is called when eviction kicks in so current size is the maximum size this cache should reach regardless whether we use entry capacity or weigher to limit the size.
        Overrides:
        updateHotMax in class AbstractEviction
      • removeFromReplacementList

        protected void removeFromReplacementList​(Entry e)
        Remove, expire or eviction of an entry happens. Remove the entry from the replacement list data structure.

        Why don't generate ghosts here? If the entry is removed because of a programmatic remove or expiry we should not occupy any resources. Removing and expiry may also take place when no eviction is needed at all, which happens when the cache size did not hit the maximum yet. Producing ghosts would add additional overhead, when it is not needed.

        Specified by:
        removeFromReplacementList in class AbstractEviction
      • checkIntegrity

        public void checkIntegrity​(IntegrityState integrityState)