Tem*_*ema 25 java memory caching
Terracotta BigMemory有没有开源替代品?
实际上我甚至没有找到任何商业选择.我对纯Java解决方案很感兴趣,它可以在JVM中运行,而不需要任何JNI和C支持的解决方案.
Maj*_*imi 19
有一个非常好的缓存解决方案,名为MapDB(以前是JDBM4).它支持HashMap和TreeMap但它是唯一的应用程序嵌入.它还支持基于持久文件的缓存.
关闭堆缓存的示例:
DB db = DBMaker.newDirectMemoryDB().make();
ConcurrentNavigableMap<Integer, String> map = db.getTreeMap("MyCache");
Run Code Online (Sandbox Code Playgroud)
或者基于持久文件的缓存:
DB db = DBMaker.newFileDB(new File("/home/collection.db")).closeOnJvmShutdown().make();
ConcurrentNavigableMap<Integer,String> map = db.getTreeMap("MyCache");
Run Code Online (Sandbox Code Playgroud)
Dan*_*ela 11
我自己一直在问这个问题,所以我只想用我的发现更新以前的答案.
我从quora找到了这个帖子,它也讨论了同样的问题:
http://www.quora.com/JVM/Whats-the-best-open-source-solution-for-java-off-heap-cache
除了directmemory(去年没有真正更新)之外,似乎更合适的不同解决方案是
但是,我还有兴趣找到一个足够大的应用程序,它使用以下三个中的任何一个:directmemory,SpyMemcached,xmemcached.如果我找到一个,我会更新这个答案.
我正在开发一个更快的解决方案,但我不建议你使用它,因为它只是现阶段的概念证明.
http://vanillajava.blogspot.com/2011/09/new-contributors-to-hugecollections.html
但是,如果您有特定要求,则可能更容易自己编码,使用直接ByteBuffers或内存映射文件.
例如
// using native order speeds access for values longer than a byte.
ByteBuffer bb = ByteBuffer.allocateDirect(1024*1024*1024).order(ByteOrder.nativeOrder());
// start at some location.
bb.position(0);
bb.put((byte) 1);
bb.putInt(myInt);
bb.putDouble(myDouble);
// to read back.
bb.position(0);
byte b = bb.get();
int i = bb.getInt();
double d = bb.getDouble();
Run Code Online (Sandbox Code Playgroud)
您可以对内存映射文件执行类似操作.内存映射文件不计入直接内存限制,也不会耗尽交换空间.
你确定BigMemory不会为你做这个工作吗?
看起来apache有一个提案:
http://wiki.apache.org/incubator/DirectMemoryProposal