K - The key classV - The value classpublic abstract class FreezingEvictor<K,V> extends Object implements EvictionInterface<K,V>
evictionComparator() returns a default
Comparator, so custom implementations that extend FreezingEvictor only need to implement
getFreezeValue(Object, TCacheHolder)| Constructor and Description |
|---|
FreezingEvictor() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterEviction()
Default implementation for
EvictionInterface.afterEviction(). |
void |
beforeEviction()
Default implementation for
EvictionInterface.beforeEviction(). |
int |
compareByFreezer(HolderFreezer<K,V> o1,
HolderFreezer<K,V> o2,
boolean includeTiebreaker)
Compare objects by their frozen value
HolderFreezer.getFrozenValue(). |
Comparator<HolderFreezer<K,V>> |
evictionComparator()
Returns the standard comparator, which compares first the frozen values, and (on ties) uses the
tiebreaker.
|
abstract long |
getFreezeValue(K key,
TCacheHolder<V> holder)
Returns a value for the given key, that may be used by the concrete implementation of the #evictionComparator().
|
public Comparator<HolderFreezer<K,V>> evictionComparator()
compareByFreezer(HolderFreezer, HolderFreezer, boolean) in the own comparator.evictionComparator in interface EvictionInterface<K,V>public void beforeEviction()
EvictionInterface.beforeEviction(). It does nothing.beforeEviction in interface EvictionInterface<K,V>public void afterEviction()
EvictionInterface.afterEviction(). It does nothing.afterEviction in interface EvictionInterface<K,V>public abstract long getFreezeValue(K key, TCacheHolder<V> holder)
Comparator.compare(Object, Object)).
While it is recommended to conform to this, it is not required - own implementations may use any other strategy,
but should document this clearly.
There are three typical usage patterns:
getFreezeValue in interface EvictionInterface<K,V>key - The keyholder - The holder that holds the associated value for the keypublic int compareByFreezer(HolderFreezer<K,V> o1, HolderFreezer<K,V> o2, boolean includeTiebreaker)
HolderFreezer.getFrozenValue(). The returned value
is negative, 0, or positive, similar to o1.getFrozenValue().compareTo(o2.getFrozenValue()).
The tie breaker in the HolderFreezer will be taken into account, if includeTiebreaker is set.o1 - The first object for the comparisono2 - The second object for the comparisonincludeTiebreaker - If true, the tie breaker will be consulted on identical elementsCopyright © 2018 trivago. All rights reserved.