Hi, afaik unfortunately there is no opportunity to implement custom ExpiryPolicy that will rely on cache entry value field for expiry calculation because there is no any hook for intercepting value during expiry policy creation or calls.

But you can use a little hacky trick with cache proxy like:


public IgniteCache<Long, Value> put(IgniteCache<Long, Value> cache, Long key, Value val) {     ExpiryPolicy expiryPolicy = new TouchedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, val.getId());     IgniteCache<Long, Value> cacheProxy = cache.withExpiryPolicy(expiryPolicy);
    cacheProxy.put(key, val);
    return cacheProxy;
}

IgniteCache cache = ignite.cache("myCache");

for (long i = 0; i < 10_000L; i++) {
    Value val = new Value(i, "value-" + i);
    cache = put(cache, i, val);
}


17.05.2021 14:09, 38797715 пишет:

Hello team,

At present, only a few simple expiration policies can be configured, such as CreatedExpiryPolicy.

If want to use a field value to determine the expiration time of the data, what should we do? Or what interface is there for extension?

Reply via email to