Class TuQueuePolicy
- java.lang.Object
-
- com.github.benmanes.caffeine.cache.simulator.policy.two_queue.TuQueuePolicy
-
- All Implemented Interfaces:
Policy,Policy.KeyOnlyPolicy
public class TuQueuePolicy extends Object implements Policy.KeyOnlyPolicy
An adaption of the 2Q algorithm used by OpenBSD and memcached. Unlike the original 2Q algorithm, non-resident entries are not retained in the TU-Q policy. For details see OpenBSD description at 2Q buffer cache algorithm and memcached's at [Work In Progress] LRU rework."We retain the key three working set distinction. In the OpenBSD code, they are named hot, cold, and warm, and each is an LRU queue. New buffers start hot. They stay that way as long as they remain on the hot queue. Eventually, a buffer will slip from the end of the hot queue onto the front of the cold queue. (We preserve the data, not just the address.) When a new buffer is needed, we recycle one from the tail of the cold queue. The oldest and coldest. If, on the other hand, we have a cache hit on a cold buffer, it turns into a warm buffer and goes to the front of the warm queue. Then as the warm queue lengthens, buffers start slipping from the end onto the cold queue. Both the hot and warm queues are capped at one third of memory each to ensure balance.
Scan resistance is achieved by means of the warm queue. Transient data will pass from hot queue to cold queue and be recycled. Responsiveness is maintained by making the warm queue LRU so that expired long term set buffers fade away."
-
-
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 TuQueuePolicy(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
-
TuQueuePolicy
public TuQueuePolicy(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.
-
-