For each node in the region you need to add an attribute which uses ExpirationAlgorithmConfig.EXPIRATION_KEY as key and a long which specifies a time-to-live for that node.
See ExpirationAlgorithm javadocs.
The javadoc mentions about expiration config being set programatically.
Cache cache; Fqn fqn1 = Fqn.fromString("/node/1"); Long future = new Long(System.currentTimeMillis() + 2000); cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future); cache.put(fqn1, "foo"); assertTrue(cache.get(fqn1) != null); Thread.sleep(5000); // 5 seconds assertTrue(cache.get(fqn1) == null);
I would like to know if it is possible to set it programatically only ?
or can we set it through the config file. What would be the setting in the config file. Is there any example for the config file setting?
Even the programatic approach as mentioned in the docs does not evict the node..
Programmatically only, and it needs to be in a region that has the expiration eviction algorithm configured.