Reputation: 219
Any one can tell me is there any Time based Trigger Policy available in Apache Ignite?
I Have an Object Having Expiry Date When That Date(Time-stamp) Expire I want to update This value and override it in Cache is it possible in Apache Ignite
Thanks in advance
Upvotes: 3
Views: 1128
Reputation: 458
Maybe like this:
cache.withExpiryPolicy(new CreatedExpiryPolicy(new Duration(TimeUnit.SECONDS, 123))).put(k, v);
The expiration will be applied only to this entry.
For trigger try continuous queries: apacheignite.readme.io/docs/continuous-queries
Upvotes: 1
Reputation: 2292
You can configure a time-based expiration policy in Apache Ignite with eager TTL: Expiry Policies. This way objects will be eagerly expired from cache after a certain time.
Then you can subscribe a javax.cache.event.CacheEntryExpiredListener, which will be triggered after every expiration, and update the cache from that listener. However, it looks like there will be a small window when the entry will have been already expired from a cache and before you put and updated value into cache.
If the above window is not acceptable to you, then you can simply query all entries from a cache periodically and update all the entries that are older than a certain expiration time. In this case you would have to ensure that all entries have a timestamp filed, which will be indexed and used in SQL queries. Something like this:
SELECT * from SOME_TYPE where timestamp > 2;
More on SQL queries here: Distributed Queries, Local Queries.
Upvotes: 1