Eviction doesn't seem to work

218 views
Skip to first unread message

micha...@gmail.com

unread,
Apr 20, 2016, 4:38:37 AM4/20/16
to guava-discuss
Hi,

I have a test where I configure CacheBuilder with expireAfterWrite of 5 seconds; I then get my thread to sleep about 15 seconds and I then enter some more items into the cache expecting to see the initial item evicted (using cache size and removelistener).
My problem is that I'm not seeing this happen i.e. no object gets evicted.  Any insight?

Thank you ,
Mike

Louis Wasserman

unread,
Apr 20, 2016, 12:17:54 PM4/20/16
to micha...@gmail.com, guava-discuss
Are you calling cleanUp()?  If nothing actually happens during that waiting period the cache won't get cleaned up, although you won't actually be able to observe the expired entries.

Certain cache configurations will result in the accrual of periodic maintenance tasks which will be performed during write operations, or during occasional read operations in the absence of writes. The Cache.cleanUp() method of the returned cache will also perform maintenance, but calling it should not be necessary with a high throughput cache. Only caches built with removalListenerexpireAfterWriteexpireAfterAccessweakKeysweakValues, orsoftValues perform periodic maintenance.

--
guava-...@googlegroups.com
Project site: https://github.com/google/guava
This group: http://groups.google.com/group/guava-discuss
 
This list is for general discussion.
To report an issue: https://github.com/google/guava/issues/new
To get help: http://stackoverflow.com/questions/ask?tags=guava
---
You received this message because you are subscribed to the Google Groups "guava-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/46a3dcb7-b2bc-4a82-a30b-4a4b52552ad2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages