ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis Magda <dma...@gridgain.com>
Subject Re: Is there a hook on cache entry expiry?
Date Wed, 30 Dec 2015 10:43:20 GMT
Hi,

When a cache entry gets expired Ignite fires EVT_CACHE_OBJECT_EXPIRED event.
Just subscribe for this kind of event notifications if you want to know when
this happens. This article [1] contains more info on how to work with events
in Ignite.

However, when a cache entry is expired it's automatically removed from a
cache, you don't need to remove expired entries manually.

To fully support your use case you can use the code snippet below as an
example:

// Create a specific expire policy for a "group" of entries you're going to
put into a cache.
ExpiryPolicy expiry = new CreatedExpiryPolicy(new Duration(MINUTES, 5));

// Get an instance to a cache with this expire policy set.
IgniteCache cache = ignite.cache("testCache").withExpiryPolicy(expiry);

// All these 10 entries will expire in 5 minutes and will be removed
automatically. The rest of the entries are not affected
for (int i = 0; i < 10; i++)
    cache.put(String.valueOf(i), i);


Regards,
Denis

[1] https://apacheignite.readme.io/docs/events



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Is-there-a-hook-on-cache-entry-expiry-tp2344p2351.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message