寻找简单的Java内存缓存 [英] Looking for simple Java in-memory cache
问题描述
我正在寻找一个简单的Java内存缓存,它具有良好的并发性(因此LinkedHashMap不够好),并且可以定期序列化到磁盘。
I'm looking for a simple Java in-memory cache that has good concurrency (so LinkedHashMap isn't good enough), and which can be serialized to disk periodically.
我需要的一个功能,但事实证明很难找到,是一种窥视对象的方法。我的意思是从缓存中检索一个对象,而不会导致缓存比其他方式更长时间地保留对象。
One feature I need, but which has proved hard to find, is a way to "peek" at an object. By this I mean retrieve an object from the cache without causing the cache to hold on to the object any longer than it otherwise would have.
更新:我忽略的另一个要求是我需要能够就地修改缓存的对象(它们包含浮点数组)。
Update: An additional requirement I neglected to mention is that I need to be able to modify the cached objects (they contain float arrays) in-place.
任何人都可以提供任何建议?
Can anyone provide any recommendations?
推荐答案
由于最初询问此问题, Google的Guava库现在包含一个功能强大且灵活的缓存。我建议使用它。
Since this question was originally asked, Google's Guava library now includes a powerful and flexible cache. I would recommend using this.
这篇关于寻找简单的Java内存缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!