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.
Currently we're using a custom cache manager for that and store some meta data separately in a file system structure.
I've looked into a couple of Java cache solutions, but none seem to match our requirements.
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.
Take a look at Infinispan. I think it covers all of your requirements.