Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for a restart-persistent LRU disk caching solution in Java - ehcache, guava, JCS do not qualify [closed]

We have an application that processes image data, running on a single machine. The processing is very expensive (10 to 30 seconds), so we cache the resulting files on disk. Those files are also big, so we have to prune the cache when it hits the configurable boundaries. The cached image files themselves are created by a different non-Java process. And there are user actions that may lead to certain cache entries becoming invalid.

Current implementation:

Currently we're using a custom cache manager for that and store some meta data separately in a file system structure.


Requirements for a caching provider:

I've looked into a couple of Java cache solutions, but none seem to match our requirements.

  1. overflow to disk (we cannot keep the entire cache in memory because RAM is very limited)
  2. persistent on shutdown, read on startup (must not be failsafe, but at least best effort)
  3. LRU eviction strategy
  4. size limitation of disk and memory cache by (different) max number of elements
  5. custom cache eviction listeners (to notify a second system)

Here's why the common frameworks don't qualify:

ehcache fails on point (1) and (2) since one cannot have both at the same time

JCS fails on point (5) as it's not possible to react to disk cache eviction events

Guava fails on point (1) as there's no overflow to disk option

Any advice is appreciated.

like image 247
pandhi Avatar asked Feb 01 '26 18:02

pandhi


1 Answers

Take a look at Infinispan. I think it covers all of your requirements.

like image 194
Shailendra Avatar answered Feb 04 '26 09:02

Shailendra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!