Skip to content

Commit

Permalink
Verify LRU stability during warmup (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfaster authored Nov 11, 2023
1 parent b027a68 commit 8b5e246
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions BitFaster.Caching.UnitTests/Lru/ConcurrentLruSoakTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BitFaster.Caching.Lru;
using FluentAssertions;
Expand Down Expand Up @@ -189,6 +190,26 @@ await Threaded.Run(4, () => {
}
}

[Fact]
public async Task WhenAddingCacheSizeItemsNothingIsEvicted()
{
const int size = 1024;

var cache = new ConcurrentLruBuilder<int, int>()
.WithMetrics()
.WithCapacity(size)
.Build();

await Threaded.Run(4, () =>
{
for (int i = 0; i < size; i++)
{
cache.GetOrAdd(i, k => k);
}
});

cache.Metrics.Value.Evicted.Should().Be(0);
}
private void RunIntegrityCheck()
{
new ConcurrentLruIntegrityChecker<int, string, LruItem<int, string>, LruPolicy<int, string>, TelemetryPolicy<int, string>>(this.lru).Validate();
Expand Down

0 comments on commit 8b5e246

Please sign in to comment.