Guava keys are segmented in concurrencyLevel different hash tables to allow multiple simultaneous reads and writes. The default value of concurrencyLevel is 4. Basically, if your maximumSize set to 100 , then it only means that each of the four segments gets a maximumSize of 25. That's why the documentation for maximumSize
Please note that the cache may display a record before this limit is exceeded. As the cache size grows to its maximum, the cache crowds out entries that are less likely to be used again.
So, if by chance, there were 30 records that went into one particular segment, then 5 of these records would be evicted.
The only way to get global eviction with the least access for Cache is to completely disable concurrency by setting concurrencyLevel(1) . Even then, the documentation does not give any guarantees regarding the order of eviction of elements, and you should not depend on it.
Louis Wasserman
source share