在同一台机器上运行的不同 JVM 之间共享 hashmap
我有一些地图包含来自数据库的缓存数据。目前,同一台服务器的 5 个实例在不同 JVM 中的同一台机器上运行。如何在 JVM 之间共享映射?缓存是一次写入,多次读取。目前的问题是因为这个缓存的JVM占用空间非常大。因此,将这个映射存储在所有 JVM 中会消耗大量内存。我需要一些可能不会消耗太多CPU时间的解决方案。有没有办法以与 JVM 之间进行类共享相同的方式来做到这一点?
谢谢 尼凯什·PL
I have some maps that contains cached data from db. Currently 5 instance of the same server is running on same machine in different JVM. How can I share maps between JVM? cache is write once and read many. Currently the problem is because of this cache JVM footprint is very big. So storing this map in all JVM is consuming lot of memory. I need some solution which may not consume much cpu time. Is there way to do this in the same way class sharing is done between JVM?
Thanks
Nikesh PL
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上,你不能:这是两个不同的地址空间。
您可以序列化一个并从另一个读取它,但这不像共享它们。
管理缓存的进程以及应用程序可用于访问数据的快速、低带宽接口怎么样?
Basically, you can't: those are two different address spaces.
You could serialize one and read it from the other, but that wouldn't be like sharing them.
How about a process to manage the cache, and a quick, low-bandwidth interface that your application programs can use to access the data?
你为什么不看看 Oracle 的 Coherence 项目呢?它不是免费的,但您可以免费下载并在开发系统上测试它。它正是您所寻找的。它用作存储数据库数据的缓存,但最终是键和值的映射。它的设置和使用非常简单。以下是帮助您入门的链接:
http://download.oracle .com/docs/cd/E13924_01/coh.340/e14135.pdf
Why dont you look at coherence a project from oracle. Its not free but you can download and test it for free on a development system. It does precisely what you are looking for. It is used as a cache for storing database data but is ultimately a map of keys and values. Its pretty simple to set up and use. Here's a link to get you started:
http://download.oracle.com/docs/cd/E13924_01/coh.340/e14135.pdf