0

The documentation is not really that clear for those two methods.
I will go with a straight question: which one should I use to free the heap from the cached objects?
Looking at the source code of LocalManualCache and LocalCache it seems invalidateAll() is the way to go, as the Segment's table's entries are setted to null.
So what is the meaning of cleanUp()?

LppEdd
  • 20,274
  • 11
  • 84
  • 139

1 Answers1

1

From the CacheBuilder Javadoc:

If expireAfterWrite or expireAfterAccess is requested entries may be evicted on each cache modification, on occasional cache accesses, or on calls to Cache.cleanUp().

cleanUp goes through and makes sure elements that have expired are actually evicted, because the design of Cache doesn't necessarily evict entries instantly when they expire. It doesn't eliminate all entries, just those that have expired. invalidateAll removes every entry in the cache.

Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413