Is there any such thing as a combination of Guava\'s Cache
and Multimap
functionality available? Essentially, I need a collection where entries expire
With a Guava Cache there is no put method, the cache is designed to be self-populating. The values returned from a key lookup are calculated at runtime. A similar approach is taken by Commons Collections Transformer Factories.
I think you could implement what you are looking for quite easily. If you look at a simple Map backed example such as Kitty-Cache you can see that you could replace the Map with a Multimap and rewrite the other methods accordingly. So in KittyCache.java internally you could have something like:
Multimap> cache;
The trick for this kind of cache is that nothing really expires until someone requests it.