Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify LRU stability during warmup #420

Merged
merged 2 commits into from
Nov 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading