-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Given this test on v2.3.2, running .net 7 on an m1 mac:
private record FakeCacheKey(int SomeProperty);
private record FakeCacheValue
{
public int SomeProperty { get; set; }
};
[Theory]
[InlineData(true)]
[InlineData(false)]
public void WhenClearingCache_ShouldActuallyClearCache(bool shouldClearTwice)
{
var cache = new ConcurrentTLru<FakeCacheKey, FakeCacheValue>(3, TimeSpan.FromMinutes(10));
var keyOne = new FakeCacheKey(1);
var keyTwo = new FakeCacheKey(2);
var cacheValue = new FakeCacheValue();
cache.AddOrUpdate(keyOne, cacheValue);
cache.AddOrUpdate(keyTwo, cacheValue);
cache.TryGet(keyOne, out var retrievedKeyValueOne);
retrievedKeyValueOne.Should().BeSameAs(cacheValue);
cache.TryGet(keyTwo, out var retrievedKeyTwoValue);
retrievedKeyTwoValue.Should().BeSameAs(cacheValue);
cache.Clear();
if (shouldClearTwice)
cache.Clear();
cache.TryGet(keyOne, out retrievedKeyValueOne);
retrievedKeyValueOne.Should().NotBeSameAs(cacheValue);
cache.TryGet(keyOne, out retrievedKeyTwoValue);
retrievedKeyTwoValue.Should().NotBeSameAs(cacheValue);
}The test is consistently failing except when the cache.Clear() is run a second time. Is this a race condition of some sort? Am i just misunderstanding what Clear() is supposed to be doing?
Stepping through the "double clear" test while watching the internal cache state:
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working


