PropagateOptions Not dealt with SlidingExpiration.
majian159 opened this issue · 2 comments
majian159 commented
IMemoryCache cache = new MemoryCache(new MemoryCacheOptions());
var random = new Random();
void Test()
{
cache.GetOrCreate("1", entry =>
{
var number = cache.GetOrCreate("2", e =>
{
e.SetAbsoluteExpiration(TimeSpan.FromSeconds(3)); //ok
e.SetSlidingExpiration(TimeSpan.FromSeconds(2));
return random.Next(0, 5);
});
return number;
});
}
Test();
while (true)
{
Console.WriteLine("1:" + cache.Get<int>("1"));
Console.WriteLine("2:" + cache.Get<int>("2"));
Thread.Sleep(2000);
}
result
1:1
2:1
1:1
2:0
1:0
2:0
SlidingExpiration Cascade expired not effective.
Tratcher commented
A sliding expiration cannot extend an entry's lifetime beyond an absolute expiration. it's also very racy that your test sleeps for exactly 2s. It might be more demonstrative if you slept for 500ms.
muratg commented
Hi. We're closing this issue as no response or updates have been provided in a timely manner and we have been unable to reproduce it. If you have more details and are encountering this issue please add a new reply and re-open the issue.