Is there a Java library to cache files? [closed]
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this questionIs there are java library that will cache files to memory and disk? Basically, I would like the library to cache the file to memory. However, if the in memory cache gets larger than a certain threshhold, some of the files should be written to disk.
Is there any Java library that will do this?
Grae
Update:
Just a couple general comment.
I am only going to开发者_StackOverflow using these files once. They are just temp files. In a perfect world, I would keep them all in memory. However, I think I would run out of memory. What I guess I am really looking for is some sort of paging system. That can keep me form running out of memory, but also allow me to avoid writting everyhting to disk.
Sure, try Terracotta or EhCache. Or Google for "java cache" and pick something else.
The OS caches files automatically. It will also automatically keep in the memory the most recently used portions of files (it can partially cache a file) I suggest you let the OS do the caching for you and find a way to efficient get data between Java and the OS.
I have had good luck with ehcache. It is very configurable.
Open Source Cache Solutions in Java
精彩评论