FluentCache icon indicating copy to clipboard operation
FluentCache copied to clipboard

Absolute expiration instead of sliding expiration?

Open bennettfactor opened this issue 7 years ago • 4 comments

Hey, I'm playing around with the dictionary cache and have configured it using ExpireAfter.

It looks like this configures it to use sliding expiration. Is absolute expiration supported? If so, how would I set the absolute expiration TimeSpan?

bennettfactor avatar Sep 21 '18 19:09 bennettfactor

Absolute expiration isn't supported natively because some cache providers don't inherently support it. You can get the desired results by specifying a validation callback - but keep in mind that this will be run client-side.

evan-rash avatar Sep 21 '18 22:09 evan-rash

Alternatively, you can specify a sliding expiration based on (absolute_expiration - now)

evan-rash avatar Sep 21 '18 22:09 evan-rash

Okay thanks, I will explore those options. My (limited) understanding is that most caching providers support this type of functionality (IDistributedCache, IMemoryCache, Redis, etc.) so would be helpful if this were included in future releases. Thanks for your help and for the great library!

bennettfactor avatar Sep 21 '18 22:09 bennettfactor

I'll look into the absolute expiration. Now that I think about it, I used to support it and took it out. I'll have to see why I removed it.

evan-rash avatar Sep 23 '18 17:09 evan-rash