.NET Ignite cache expiry policy not working

257 views Asked by At

I am trying to set a global expiring policy to a Ignite cache but it doesn't work, all the entries are still there even after the timeout value. This is how I am implementing it:

var igniteCache = this.igniteInstance.GetOrCreateCache<string, object>(configuraton);

var expiringTime = TimeSpan.FromSeconds(100);
igniteCache.WithExpiryPolicy(new ExpiryPolicy(expiringTime, expiringTime, expiringTime));

igniteCache.Put(key, value);

What am I doing wrong?

1

There are 1 answers

2
Pavel Tupitsyn On BEST ANSWER

WithExpiryPolicy returns a new cache instance, you should use it to insert entries with expiration:

var igniteCacheExpiry = igniteCache.WithExpiryPolicy(new ExpiryPolicy(expiringTime, expiringTime, expiringTime));

igniteCacheExpiry.Put(key, value)