1

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.

2
  • How you would solve this depends on what kind of environment you are implementing the application for. Is it a webapp? If so, which server are you using? Is it a desktop app? Then there is a different story. Try to me more precise in your question. Commented Aug 29, 2013 at 11:26
  • 1
    Your OS should cache the file anyway, so I think it's usually no point in caching a few files. Try doing a test... load the file twice and measure the time. Commented Aug 29, 2013 at 11:35

3 Answers 3

2

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

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

Hope this helps

Sign up to request clarification or add additional context in comments.

Comments

0

Ehcache is also a good one.
Try this

Comments

0

You can have a look at Cacheonix. Cacheonix is an open source distributed data management framework for Java. For more details on File Caching , read

http://www.cacheonix.com/articles/How_to_Cache_a_File_in_Java.htm

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.