Hazelcast 中地图的编程属性设置?
有没有办法以编程方式为 Hazelcast 中的分布式地图设置“生存时间”属性(或者实际上是任何属性)?
我想避免为此更改 Hazelcast 配置 XML。
我使用的是 Hazelcast 版本 1.7.1
Is there a way to programmatically set the "time to live" property (or in fact, any property) for a distributed map in Hazelcast?
I want to avoid having to change the Hazelcast config XML for this.
I am using Hazelcast version 1.7.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 1.7.1 版本开始,您可以在 Hazelcast 中以编程方式设置所有内容。
您需要创建一个 Config 对象并传递它。
这是在 Hazelcast 1.7.1 中执行此操作的方法
如果您使用 Hazelcast 静态方法来获取地图,例如 Hazelcast.getMap("myMapName"),则方法如下:
但如果您使用 Hazelcast.newHazelcastInstance 创建 Hazelcast 实例,则通过此方法的配置。然后从实例获取地图。这样你就可以在同一个 JVM 中创建多个 hazelcast 实例。以下是 hazelcast 最新版本中的代码
,创建配置对象更加简单:
顺便说一句,Hazelcast 1.8.1 Final 即将发布。我建议你切换到那个版本。
干杯...
You can set everything programmatically in Hazelcast starting with 1.7.1 version.
You need to create a Config object and pass it.
Here is how you do it in Hazelcast 1.7.1
If you are using Hazelcast static methods to get map, like Hazelcast.getMap("myMapName") then this is the way:
But if you are creating Hazelcast instances with Hazelcast.newHazelcastInstance then pass the config to this method. then get map from the instance. This way you can create multiple hazelcast instances in same JVM. Here is the code
In hazelcast latest version creating the config object is even simpler:
By the way Hazelcast 1.8.1 final is about to release. I suggest you to switch to that version.
Cheers...