How can I get AbsoluteExpiration DateTimeOffset of key in IMemoryCache

Viewed 316

I add a value to IMemoryCache

_cache.Set("Key", "Value", DateTimeOffset.UtcNow);

I wanna to get absolute expiration value of this key in other methods.

Or

I wanna to update value of this key without changing expiration.

How can i do that?

In IMemoryCache document doesn't have any way to get it (at least i didn't see), I handle it by caching expiration. Is there any better solution for handle it?

1 Answers

IMemoryCache (as in its documentation) doesn't have any method to get item expiration. Same for its default implementation MemoryCache.

Related