The Guava cache is designed to cushion the lock, and the cleanUp method causes the cache to arrive in a consistent state. The Map.size() method is approximate, but can count records pending deletion due to an expiration or eviction link. The visibility of approximations in the Guava cache is rarely of great interest to an application, which usually considers the cache as a temporary data store. Various expectations of the cache from the Map led to the asMap method to allow the cache to be considered as a map, but developers do not like to perceive it in this way.
Details of the cache implementation were described at the StrangleLoop 2011 slides conference. The ConcurrentLinkedHashMap project document from which the GuoWa cache was obtained may also be of interest, but it describes a slightly different approach.
Ben manes
source share