2 years ago

#56223

test-img

Master Qiao

How Cache in Guava deletes its expired items, using a timer thread or checking items' validity when access them

I'm using Guava's cache in my program. I expected Guava may use a timer thread to expire its items, but I checked the source code and it seems Guava would clear its expired items only when program tries to access its items. I'm not sure if that's the way Guava's cache works.

Here's my requirement. My program works with several huge objects which loaded from files. Once a huge object get in use, the object may be accessed several times in consecutive several minutes, and then the cache would not be accessed at all in a long time. I prefer the object can be cleared as soon as possible just as expireAfterAccess(10min) or clearedAfterAccess(10min).

java

guava

0 Answers

Your Answer

Accepted video resources