Open MonDeveloper opened 6 years ago
Funny right?
That's how the Microsoft.Extensions.Caching.Memory
works. It does not have any kind of background job to run cleanup tasks.
You have do perform an(y) action on the cache to trigger cache invalidation, e.g. Add
or Get
a key.
Then, the MemoryCache thing runs an invalidation if the last invalidation ran more than MemoryCacheOptions.ExpirationScanFrequency
ago...
To see that in action, change your code and add something like the following instead of your Task.Delay
while (true)
{
await Task.Delay(TimeSpan.FromSeconds(5));
Console.WriteLine(cache.Add("key1", 1));
}
Since my test is a very few steps beyond the "Hello World" of your amazing CacheManager I'm pretty sure I'm failing somewhere but I'm totally blind and I can't get out of it by myself.
As the Issue title says, using the Extension.Caching I'm not able to catch any eviction event, here there is my test code, if you switch the two handles (commented / uncommented) everything works as expected. Please, point me in the right direction sir,
I noticed your library still references an old version of
Microsoft.Extensions.Caching.Memory
1.0.2 while that library now reached the 2.1.1 version, I tried to directly reference some of the more recent versions but the outcomes are always the same, the event is never triggered.