using Microsoft.Extensions.Caching.Memory;
public static void Main()
var cacheEntryOptions = new MemoryCacheOptions();
cacheEntryOptions.ExpirationScanFrequency = TimeSpan.FromSeconds(1);
var m = new MemoryCache(cacheEntryOptions);
m.Set<object>($"asdsa{x}", null, TimeSpan.FromMilliseconds(2));
Console.WriteLine(m.Count);
Console.WriteLine($"final count {m.Count}");
m.Set<object>($"asdsa", null, TimeSpan.FromMilliseconds(2));
Console.WriteLine($"final count2 {m.Count}");