For example, I would like to configure the cache with the following two expiry policies:
- TouchedExpiryPolicy
- CreatedExpiryPolicy
The sample code is as below (Apache Ignite version 1.5.0.final):
public IgniteCache<String, Object> getOrCreateCache(String cacheName) {
Ignite ignite = Ignition.ignite();
CacheConfiguration<String, Object> cacheCfg = new CacheConfiguration<String, Object>(cacheName);
cacheCfg.setExpiryPolicyFactory(TouchedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 10)));
cacheCfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 30)));
IgniteCache<String, Object> igniteCache = ignite.getOrCreateCache(cacheCfg);
return igniteCache;
}
The problem is, however, that the second expiry policy will replace the first one. Wonder if there is any way I can configure the Ignite cache so that the cache will honour both expiry policies? Thank you.
By the way, in EhCache, I can achieve the same thing by configuring the cache the following way:
<cache name="my-cache-name" ...
timeToIdleSeconds="10" timeToLiveSeconds="30"
...>
</cache>
References: