2

Is there a way to not cache elements using Guava Cache if maximumSize reached? I'm looking for behaviour similar to "No ejection" option in couchbase:

If No ejection is selected, no ejection of existing data occurs, and attempts to cache new data fail.

I want cache to be cleared using "expireAfterAccess" option only.

Stanislav
  • 61
  • 5
  • 2
    You could maintain a soft threshold count using `CacheLoader` and `RemovalListener`, and throw an exception on a load if the max was reached. That won't be strict, but may be good enough – Ben Manes Sep 20 '18 at 01:58
  • To confirm, you're looking for subsequent cache attempts to fail, not just silently be skipped, correct? – dimo414 Sep 20 '18 at 23:53
  • I will be satisfied with 'silent skipping' solution :) – Stanislav Sep 21 '18 at 07:04

0 Answers0