I would like to set the expiry time of a member of an cache. I want the custom ttl when the object should expire. I know I can set it for the whole cache, e.g.
Cache cache = manager.getCache("MyCache");
CacheConfiguration config = cache.getCacheConfiguration();
config.setTimeToIdleSeconds(60);
config.setTimeToLiveSeconds(120);
config.setMaxEntriesLocalHeap(10000);
config.setMaxEntriesLocalDisk(1000000);
In Ehcache 2.x, We can set expiry time on the Element we insert in the cache:
Element element = new Element("key1", "value1"); element.setTimeToLive(100);
Do we have any other java open source library like that support similar feature as above as Ehcache 3.x doesnot support this.
Ideally I would like to have the following interface:
put(key, value, timeToLive)// enter a key and value with a specified timeToLIve(ttl)
put(key, value) // enter a key value with no timeToLive