K - the type of keys maintained by IMapV - the type of mapped valuespublic abstract class MapEvictionPolicy<K,V> extends Object implements Comparator<EntryView<K,V>>
MaxSizePolicies
and it helps to find most appropriate entries to remove.
IMap has out-of-the-box eviction policies like LRUEvictionPolicy,
LFUEvictionPolicy and RandomEvictionPolicy but if there is a need to define another eviction policy,
users can introduce a custom one by extending MapEvictionPolicy class.
Implementation:
compare(EntryView, EntryView) method must be implemented to provide an ascending order
of entries. Because internal eviction algorithm will evict the smallest entry from IMapLRUEvictionPolicy,
LFUEvictionPolicy,
RandomEvictionPolicy| Constructor and Description |
|---|
MapEvictionPolicy() |
| Modifier and Type | Method and Description |
|---|---|
abstract int |
compare(EntryView<K,V> entryView1,
EntryView<K,V> entryView2) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic abstract int compare(EntryView<K,V> entryView1, EntryView<K,V> entryView2)
If you prefer to evict the 1st entry then return negative number, if the 2nd entry is a better candidate then return a positive number or return 0 if both entries are equally good candidates for eviction
compare in interface Comparator<EntryView<K,V>>Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.