I am trying to build a simple caching system for caching entries from a database table, and I would like each individual entry in the Cache to have a different expiration time. Are there any Java caching libraries with the ability to set different expiration times for each individual entry in the cache?

P.S: I know REDIS does this but it is way too heavy for my use-case. Looking for something more lightweight. I looked at guava LoadingCache and EhCache. However both of these seem to have a global expiration timeout for ALL entries in the Cache. I am looking for something more fine grained.


  • What do you mean by lightweight? Should it run embedded in your app? Stored in memory? Should the cache disappear when your app shuts down?
    – Nicolas Raoul
    Commented Apr 5, 2016 at 8:09

1 Answer 1


It's been a few months since you posted your request, but please consider FeCache

FeCache is an extremely lightweight simple caching library in Java which allows entries to be cached with different expiration times, specified in milliseconds - that is, each entry can be given a different time-to-live. I hope I'm using the term correctly here: it's FOSS, licensed under the Apache 2.0 license.

I think it meets both of your requirements:

  • Each individual entry in the Cache can have a different expiration time
  • It is definitely more lightweight than Redis (the jar including the unit tests is 7492 bytes)

Disclaimer: I am the author of FeCache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.