Using Caffeine for values on disk

1.7k Views Asked by At

I'm thinking about using Caffeine for values off-loaded to disk. The keys are small, but the values may take a few megabytes. I guess, I can rely on a RemovalListener for cleaning up the mess.

For limiting the disk usage, I can use Caffeine.weigher. However, maximumWeight can not be used together with maximumSize, so it may happen that I run out of memory (because of using many cache entries) before my disk fills enough to cause eviction.

I guess, it's improbable, but possible, as there's no lower bound on the average entry size.

  • Does such a use of an in-memory cache make sense?
  • Is there a good reason why maximumSize and maximumWeight are mutually exclusive? I can imagine that both share a single slot, but saving eight bytes per cache IMHO doesn't count.
  • Is there a trick to circumvent this restriction?
0

There are 0 best solutions below