Hi,
Ignite uses JCache’s ExpiryPolicy, and that API only provides a way to specify
three kinds of TTL – for creation, modification and access.
AFAIU you’d like to tune TTL on a finer level, having different values per
different operations. If so, you can’t do that just with ExpiryPolicy.
But you can create several views of a cache with IgniteCache::withExpiryPolicy,
and use them to perform operations with different effect on the TTL.
try (Ignite ignite =
Ignition.start("examples/config/example-ignite.xml")) {
IgniteCache<String, String> cache =
ignite.getOrCreateCache("MyCache");
IgniteCache<String, String> eternalCache =
cache.withExpiryPolicy(new EternalExpiryPolicy());
IgniteCache<String, String> temporaryCache =
cache.withExpiryPolicy(new CreatedExpiryPolicy(new Duration(TimeUnit.SECONDS,
10)));
eternalCache.put("eternal", "foo");
temporaryCache.put("temp", "bar");
System.out.println("Before sleep:");
System.out.println(cache.get("eternal"));
System.out.println(cache.get("temp"));
Thread.sleep(10_000);
System.out.println("After sleep:");
System.out.println(cache.get("eternal"));
System.out.println(cache.get("temp"));
}
Output of that is:
Before sleep:
foo
bar
After sleep:
foo
null
Stan
From: Ariel Tubaltsev
Sent: 23 января 2018 г. 2:51
To: [email protected]
Subject: Key Value Store - control TTL refresh
I'd like to set TTL for all entries in some map.
Along with that I'd like to control operations that refresh TTL. For
instance simple Read/Write should update the TTL, but pulling the whole map
should not.
Is that something that can be done with current expiry policies?
https://apacheignite.readme.io/docs/expiry-policies
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/