Caching in Java with Singleton Pattern

I want to send some file(s) to cache and read them from cache in Java. I’ve been searching for this on the internet but there are many advanced stuff for caching. I’ve downloaded ehcache but couldn’t find a way to work things out. Is there a library for just caching and reading files from cache in java? I’m kinda new in Java, therfore I don’t understand advanced stuff easily.

Thank you for your help.


Google Guava provide simple way to implement cache in your application.

LoadingCache<Key, Graph> graphs = CacheBuilder.newBuilder()
       .expireAfterWrite(10, TimeUnit.MINUTES)
           new CacheLoader<Key, Graph>() {
             public Graph load(Key key) throws AnyException {
               return createExpensiveGraph(key);

Hope this helps

Leave a Reply

Your email address will not be published. Required fields are marked *