0
EvictionConfig evictionConfig = new EvictionConfig()
                    .setEvictionPolicy(EvictionPolicy.LFU)
                    .setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.ENTRY_COUNT)
                    .setSize(10000);

NearCacheConfig nearCacheConfig = new NearCacheConfig()
                    .setName("nearcache")
                    .setEvictionConfig(evictionConfig);

ClientConfig clientConfig = new ClientConfig();
clientConfig.addNearCacheConfig(nearCacheConfig);

/* Accessing the Map */

IMapJet<String,String> map = jet.getMap("nearcache");

 for(String key: map.keySet()){
         String value = map .get(key);
 }

NearCacheStats nearCacheStatistics = map.getLocalMapStats().getNearCacheStats();

System.out.println( "Near Cache hit/miss ratio = "
                + nearCacheStatistics.getHits());

我作为 Java 客户端连接到 Hazelcast 集群,getMap 返回一些值,因此我没有向地图插入任何值,因为它包含大约 200 个值。

nearCacheStatistics 返回 NullPointerException。谁能告诉我我做错了什么?

4

0 回答 0