We can write our own comparator to select the entries to evict first. The SortedEvictionPolicyFactory can be configured for custom sorting.
The eviction policy removes entries from the on-heap and off-heap caches to prevent OOM errors. We can also configure a swap space to prevent OOM errors. The following section will explain what a swap space is and how can we configure it.