I have Microsoft Office files which I need to store in Google Guava cache. The key will be fileid and the value will be actual word document. I have that word document in the ByteArrayOutput stream but storing ByteArrayOutput stream is not a good idea. Any other thought ?

有帮助吗?

解决方案

If you really want to cache the binary content you could write the outputstream to a byte array and cache that array, but I would recommend to try the solution from Peter Lawrey first. The only performance penality would be that you need to read the file through the OS, but it is hard to image that, you do so many operations that this would be a problem.

其他提示

The OSes disk cache already caches in files in memory that you might like to use later. I would make use of that first. This means all you need to cache is meta data like files name

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top