alastairtree / LazyCache

An easy to use thread safe in-memory caching service with a simple developer friendly API for c#
https://nuget.org/packages/LazyCache
MIT License
1.72k stars 159 forks source link

Absolute expiration of 7 seconds or less doesn't work #20

Closed azharmahmood closed 6 years ago

azharmahmood commented 7 years ago

Hello, I need absolute expiration of 7 seconds or less, but it does not expire below 15 seconds for me. Looks like there is a bug in MemoryCache, I think the same bug is causing this.

For MemoryCache folks are using a solution to override that property through reflection (please see this thread https://stackoverflow.com/questions/12630168/memorycache-absoluteexpiration-acting-strange)

What would be the best way to incorporate that in your solution, please advise?

alastairtree commented 7 years ago

You would need to create your own instance of the overridden MemoryCache with the shortened expiry timer and then pass that into the constructor of the CachingService

ObjectCache innerCache = new HackedUpMemoryCacheWithShortTimer();
IAppCache cache = new CachingService(innerCache);
alastairtree commented 6 years ago

No reply for a while, closing.