如何为 Java 应用程序创建一个简单的分布式 Map?
我正在寻找一个 Map 来在不同机器上运行的 Java Web 应用程序的两个实例之间共享信息。对该映射的读取和写入需要非常快,并且不必是事务性的,即如果一个实例有一段时间有过时的数据也可以。
有什么建议吗?
我需要跟踪用户上次在应用程序中执行某些操作的时间,因此如果此信息已过时,也并不是很糟糕。速度和易用性很重要。我不希望写入映射影响响应时间。
I am looking for a Map to share information between two instances of a Java web application running on separate machines. Reads and writes to this map need to be very fast and don't have to be transactional i.e. its ok if one instance has stale data for a while.
Any recommendations?
I need to keep track of the last time a user did something in the application, so its not terribly bad if this information is out of date. Speed and ease of use are important. I don't want writes to the Map to impact response times.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会尝试 Hazelcast、JGroups 或 Ehcache。全部都支持分布式地图。
编辑:另一种选择是使用 RMI 来运行在一个或另一个 JVM 中的服务。这避免了对额外库的需要。
I would try Hazelcast, JGroups or Ehcache. All support a distributed map.
EDIT: Another option is to use RMI top a service running in one or the other JVM. This avoids the need for an additional library.
此外,还有 Memcached,它非常强大并且经过了时间的考验。
Additionally, there is Memcached which is very robust and proven over the time.