nearCacheConfig.setTimeToLiveSeconds(Integer.parseInt(value)); } else if ("max-idle-seconds".equals(nodeName)) { nearCacheConfig.setMaxIdleSeconds(Integer.parseInt(value)); } else if ("eviction-policy".equals(nodeName)) { nearCacheConfig.setEvictionPolicy(value);
nearCacheConfig.setTimeToLiveSeconds(Integer.parseInt(value)); } else if ("max-idle-seconds".equals(nodeName)) { nearCacheConfig.setMaxIdleSeconds(Integer.parseInt(value)); } else if ("eviction-policy".equals(nodeName)) { nearCacheConfig.setEvictionPolicy(value);
nearCacheConfig.setTimeToLiveSeconds(Integer.parseInt(value)); } else if ("max-idle-seconds".equals(nodeName)) { nearCacheConfig.setMaxIdleSeconds(Integer.parseInt(value)); } else if ("eviction-policy".equals(nodeName)) { nearCacheConfig.setEvictionPolicy(value);
nearCacheConfig.setTimeToLiveSeconds(Integer.parseInt(value)); } else if ("max-idle-seconds".equals(nodeName)) { nearCacheConfig.setMaxIdleSeconds(Integer.parseInt(value)); } else if ("eviction-policy".equals(nodeName)) { nearCacheConfig.setEvictionPolicy(value);
public NearCacheConfig asNearCacheConfig(SerializationService serializationService) { NearCacheConfig config = new NearCacheConfig(); config.setName(name); config.setInMemoryFormat(inMemoryFormat); config.setSerializeKeys(serializeKeys); config.setInvalidateOnChange(invalidateOnChange); config.setTimeToLiveSeconds(timeToLiveSeconds); config.setMaxIdleSeconds(maxIdleSeconds); config.setEvictionConfig(evictionConfigHolder.asEvictionConfg(serializationService)); config.setCacheLocalEntries(cacheLocalEntries); config.setLocalUpdatePolicy(LocalUpdatePolicy.valueOf(localUpdatePolicy)); config.setPreloaderConfig(preloaderConfig); return config; }
public NearCacheConfig asNearCacheConfig(SerializationService serializationService) { NearCacheConfig config = new NearCacheConfig(); config.setName(name); config.setInMemoryFormat(inMemoryFormat); config.setSerializeKeys(serializeKeys); config.setInvalidateOnChange(invalidateOnChange); config.setTimeToLiveSeconds(timeToLiveSeconds); config.setMaxIdleSeconds(maxIdleSeconds); config.setEvictionConfig(evictionConfigHolder.asEvictionConfg(serializationService)); config.setCacheLocalEntries(cacheLocalEntries); config.setLocalUpdatePolicy(LocalUpdatePolicy.valueOf(localUpdatePolicy)); config.setPreloaderConfig(preloaderConfig); return config; }
cacheMapNLConfig.setInMemoryFormat(InMemoryFormat.OBJECT); cacheMapNLConfig.setInvalidateOnChange(true); cacheMapNLConfig.setMaxIdleSeconds(10 * 60); /* 10 minute idle time */ cacheMapNLConfig.setTimeToLiveSeconds(1 * 60 * 60); /* 1 hour TTL */ cacheMapConfig.setNearCacheConfig(cacheMapNLConfig);
public void run() { NearCacheConfig nearCacheConfig = createNearCacheConfig() .setInMemoryFormat(InMemoryFormat.OBJECT) .setCacheLocalEntries(true) .setInvalidateOnChange(false) .setMaxIdleSeconds(MAX_IDLE_SECONDS) .setEvictionConfig(createEvictionConfigWithEntryCountPolicy(RECORD_COUNT * 2)); ICache<Integer, Article> cache = createCacheWithNearCache(nearCacheConfig); cache.put(1, new Article("foo")); printNearCacheStats(cache, "The put(1, article) call has no effect on the empty Near Cache"); cache.get(1); printNearCacheStats(cache, "The first get(1) call populates the Near Cache"); // with this short sleep time, the Near Cache entry should not expire for (int i = 0; i < 20; i++) { cache.get(1); sleepMillis(100); } printNearCacheStats(cache, "We have called get(1) every 100 ms, so the Near cache entry could not expire"); waitForExpirationTask(MAX_IDLE_SECONDS); printNearCacheStats(cache, "We've waited for max-idle-seconds, so the Near Cache entry is expired."); cache.get(1); printNearCacheStats(cache, "The next get(1) call is fetching the value again from the cache"); HazelcastClient.shutdownAll(); Hazelcast.shutdownAll(); }
NearCacheConfig codeCacheConfig = new NearCacheConfig(); codeCacheConfig.setTimeToLiveSeconds(60 * 60 * 1000); // 1 hour TTL codeCacheConfig.setMaxIdleSeconds(10 * 60 * 1000); // 10 minutes max idle seconds codeCacheConfig.setInMemoryFormat(InMemoryFormat.OBJECT); codeCacheConfig.setCacheLocalEntries(true); // this enables the local caching NearCacheConfig referenceCacheConfig = new NearCacheConfig(); referenceCacheConfig.setTimeToLiveSeconds(60 * 60 * 1000); // 1 hour TTL referenceCacheConfig.setMaxIdleSeconds(10 * 60 * 1000); // 10 minutes max idle seconds referenceCacheConfig.setInMemoryFormat(InMemoryFormat.OBJECT); referenceCacheConfig.setCacheLocalEntries(true); // this enables the local caching