| I am trying to understand guava cache cleanup behaviour. Based on doc I read, it is not necessary that expired items in the cache would be removed until cache is accessed again. To ensure expired items are removed, we should invoke cache.cleanup(). Also, I observed in the code base that maximum number of items during single cleanup is limited to 16. Consider the following scenario: The cache is defined with expireAfterAccess defined at 10 seconds. Suppose after 1 minute of cache access, the requests to cache stop and restart after 5 minutes later. Let us assume that cache contained 10,000 items when traffic to cache stopped. Thus, when the traffic to cache restarts, all items in the cache would be expired. So when the first request after the 5 minute duration tries to access the cache, only 16 of these items would be removed. Even if I forcefully invoke, cache.cleanup() before the first access(either read or write), only 16 items would get removed. I wanted to define business logic based on RemovalListener so I need all expired items to be removed from cache. Is my understanding correct? If so, my calculation for the first request would be wrong as not all expired items would get removed from cache. What is the best alternative around this? Thanks |
--
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/2cd6579d-8b69-40c9-b3d6-5b5d8e19604e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/fbcccb9e-dce8-4388-81d9-5e922acd971f%40googlegroups.com.
I wanted to define business logic based on RemovalListener so I need all expired items to be removed from cache.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/fbcccb9e-dce8-4388-81d9-5e922acd971f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/CAGB9EW_aEqHWGdOi9iwhuCPF6JARdNSCaH0nTOP4E2_9GyCdRQ%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to guava-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/fbcccb9e-dce8-4388-81d9-5e922acd971f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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.
Probably using cache, might not be best data structure for me given my use case. I probably need to come up with custom solution.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/ce482c1b-871b-43a5-9bc5-7ebaedfd6d4b%40googlegroups.com.