Class TwoQueuePolicy
- java.lang.Object
-
- com.github.benmanes.caffeine.cache.simulator.policy.two_queue.TwoQueuePolicy
-
- All Implemented Interfaces:
Policy,Policy.KeyOnlyPolicy
public final class TwoQueuePolicy extends Object implements Policy.KeyOnlyPolicy
The 2Q algorithm. This algorithm uses a queue for items that are seen once (IN), a queue for items seen multiple times (MAIN), and a non-resident queue for evicted items that are being monitored (OUT). The maximum size of the IN and OUT queues must be tuned with the authors recommending 20% and 50% of the maximum size, respectively.This implementation is based on the pseudocode provided by the authors in their paper 2Q: A Low Overhead High Performance Buffer Management Replacement Algorithm. For consistency with other policies, this version places the next item to be removed at the head and most recently added at the tail of the queue.
-
-
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 TwoQueuePolicy(Config config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
finished, name
-
Methods inherited from interface com.github.benmanes.caffeine.cache.simulator.policy.Policy.KeyOnlyPolicy
record
-
-
-
-
Constructor Detail
-
TwoQueuePolicy
public TwoQueuePolicy(Config config)
-
-
Method Detail
-
record
public void record(long key)
- Specified by:
recordin interfacePolicy.KeyOnlyPolicy
-
stats
public PolicyStats stats()
Description copied from interface:PolicyReturns the cache efficiency statistics.
-
-