We are trying to have custom expiry for each record in our map. Each object has the field 'long expireDate' which is time in millis when we want the object to be removed.
Are we able too implement some policy to remove records based on the value of this field for each entry?
Looked into this question but this is per entry via a put. Setting TTL/Record Expiry in hazelcast
IMap::put(Key, Value, TTL, TimeUnit)
The issue with this is 95% of our entries are placed there using a putAll and hence it cant be provided this way.
The IMap.setTTL() method, available in IMDG 3.11 and later, allows you to set individual TTL values on entries within the Map. I think the solution here would be to write a small procedure that reads the entry's expireDate value, calculates an offset from current system time, and sets the TTL for the map entry to that offset.
This procedure could then be executed as either an EntryProcessor (perhaps immediately following a putAll operation, using the same set of keys), or as a MapListener that would be triggered whenever an entry was added (or updated, if updates sometimes alter the expireData value).