Class ClockProSimplePolicy
- java.lang.Object
-
- com.github.benmanes.caffeine.cache.simulator.policy.irr.ClockProSimplePolicy
-
- All Implemented Interfaces:
Policy,Policy.KeyOnlyPolicy
public final class ClockProSimplePolicy extends Object implements Policy.KeyOnlyPolicy
The ClockPro algorithm. This algorithm differs from LIRS by replacing the LRU stacks with Clock (Second Chance) policy. This allows cache hits to be performed concurrently at the cost of a global lock on a miss and has the worst case time of O(n) on eviction due to queues being scanned.ClockPro uses three hands that scan the queue. The hot hand points to the largest recency, the cold hand to the cold entry furthest from the hot hand, and the test hand to the last cold entry in the test period. This policy is adaptive by adjusting the percentage of hot and cold entries that may reside in the cache. It uses non-resident (ghost) entries to retain additional history, which are removed during the test hand's scan. The 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. This implementation works exactly like ClockPro, but pursues the simplicity of the code. It divides a single list of ClockPro into three lists: hot, cold, and non-resident. For maintaining a test period of each entry, it uses epoch.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.github.benmanes.caffeine.cache.simulator.policy.Policy
Policy.Characteristic, Policy.KeyOnlyPolicy, Policy.PolicySpec
-
-
Constructor Summary
Constructors Constructor Description ClockProSimplePolicy(Config config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfinished()Indicates that the recording has completed.voidrecord(long key)PolicyStatsstats()Returns the cache efficiency statistics.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.benmanes.caffeine.cache.simulator.policy.Policy.KeyOnlyPolicy
record
-
-
-
-
Constructor Detail
-
ClockProSimplePolicy
public ClockProSimplePolicy(Config config)
-
-
Method Detail
-
stats
public PolicyStats stats()
Description copied from interface:PolicyReturns the cache efficiency statistics.
-
finished
public void finished()
Description copied from interface:PolicyIndicates that the recording has completed.
-
record
public void record(long key)
- Specified by:
recordin interfacePolicy.KeyOnlyPolicy
-
-