Guava team member here.
As the cache size grows to its maximum, the cache crowds out entries that are less likely to be used again. For example, a cache may display a record because it has not been used recently or very often.
If the cache has any other behavior, it is not documented (and should not be relied on). However, the current implementation only cares that access has recently been gained if you look at the source :
while (totalWeight > maxSegmentWeight) { ReferenceEntry<K, V> e = getNextEvictable(); if (!removeEntry(e, e.getHash(), RemovalCause.SIZE)) { throw new AssertionError(); } }
and getNextEvictable iterates in the order of least available access.
Louis Wasserman
source share