寻找简单的 Java 内存缓存 [英] Looking for simple Java in-memory cache

查看:28
本文介绍了寻找简单的 Java 内存缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个简单的 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.

谁能提供任何建议?

推荐答案

既然最初问这个问题,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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆