[英]How to configure NearCache with Hazelcast 3.5 without an explicit Client
Based on this question , I'm trying to switch to the version 3.5-EA of Hibernate. 基于这个问题 ,我试图切换到Hibernate的3.5-EA版本。
Up to now I had a configuration like this: 到目前为止,我有这样的配置:
CacheConfiguration<K, V> configuration = new CacheConfig<K, V>()
.setNearCacheConfig(new NearCacheConfig().setInMemoryFormat(InMemoryFormat.OBJECT))
.setExpiryPolicyFactory(createExpiryPolicyFactory(expiryDuration));
cache = cacheManager.createCache(cacheName, configuration);
But now the setNearCacheConfig
method is gone. 但是现在
setNearCacheConfig
方法不见了。 There only exists a addNearCacheConfig
on the ClientCacheConfig
. ClientCacheConfig
上仅存在一个addNearCacheConfig
。 But I don't have a ClientCacheConfig
. 但是我没有
ClientCacheConfig
。
I basically don't know where to put the NearCacheConfig
. 我基本上不知道将
NearCacheConfig
放在NearCacheConfig
。
the configuration of the nearcache can be done on the client side. Nearcache的配置可以在客户端完成。 http://docs.hazelcast.org/docs/3.5/manual/html-single/hazelcast-documentation.html#hazelcast-java-client
http://docs.hazelcast.org/docs/3.5/manual/html-single/hazelcast-documentation.html#hazelcast-java-client
If you do not want to use xml for configuration ( http://docs.hazelcast.org/docs/latest/manual/html-single/hazelcast-documentation.html#near-cache ) - you could probably do something like this - 如果您不想使用xml进行配置( http://docs.hazelcast.org/docs/latest/manual/html-single/hazelcast-documentation.html#near-cache ),则可以执行以下操作-
Config cfg = new Config();
MapConfig mc = new MapConfig();
mc.setNearCacheConfig(new NearCacheConfig());
cfg.addMapConfig(mc);
HazelcastInstance hi = Hazelcast.newHazelcastInstance(cfg);
As per my opinion, NearCache feature is useful when you are using Client-Server hazelcast api and when youa re trying to access cache externally, but if you are gonna make call within hazelcast cluster internally and do not want to use Hazelcast client api than there no need to use NearCache feature. 根据我的观点,当您使用Client-Server hazelcast api并尝试从外部访问缓存时,NearCache功能很有用,但是如果您要在hazelcast集群内部进行调用并且不想使用Hazelcast客户端api,无需使用NearCache功能。 Since there will not be any benefit out of it.
既然不会有任何好处。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.