I have a java file server that serves the file via http. Each file is uniquely addressed by an identifier, for example:
http:
I want to add a cache layer to it so that files with the most frequently used access are stored in memory. I would also like to control the overall cache size. I am thinking of using ehcache or oscache for this, but I only used them to cache the serialized object before. Are they a good choice and are there any additional considerations for creating a file cache?
Edit
Thanks for all the answers. Some file server details simplify (or complicate) the problem:
- After saving the file, it never changes.
- MD5 hash to avoid duplicate files when saving. (I am aware of potential collisions and security issues)
- A file server running in Linux boxes.
Edit 2
Although the server itself does not impose any restrictions on the type of file that it supports, files are mainly images (jpg, gif, pgn), Word, excel, PDF no more than 10 MB.
source
share