How to configure NearCache with Hazelcast 3.5 without an explicit Client

萝らか妹 提交于 2020-01-25 20:23:32

问题


Based on this question, I'm trying to switch to the version 3.5-EA of Hibernate.

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. There only exists a addNearCacheConfig on the ClientCacheConfig. But I don't have a ClientCacheConfig.

I basically don't know where to put the NearCacheConfig.


回答1:


the configuration of the nearcache can be done on the client side. http://docs.hazelcast.org/docs/3.5/manual/html-single/hazelcast-documentation.html#hazelcast-java-client




回答2:


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 -

    Config cfg = new Config();
    MapConfig mc = new MapConfig();
    mc.setNearCacheConfig(new NearCacheConfig());
    cfg.addMapConfig(mc);
    HazelcastInstance hi = Hazelcast.newHazelcastInstance(cfg);



回答3:


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. Since there will not be any benefit out of it.



来源:https://stackoverflow.com/questions/30913938/how-to-configure-nearcache-with-hazelcast-3-5-without-an-explicit-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!