Add IAsyncAlternateLookup support to ConcurrentLfu#744
Open
Conversation
Agent-Logs-Url: https://github.com/bitfaster/BitFaster.Caching/sessions/48a316a7-05ab-44a4-9138-7763402ac8fc Co-authored-by: bitfaster <12851828+bitfaster@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
bitfaster
March 30, 2026 05:54
View session
Owner
|
@copilot Add the |
…entTLfu Agent-Logs-Url: https://github.com/bitfaster/BitFaster.Caching/sessions/cdf947fa-1566-46de-86ab-7a60a3b24e48 Co-authored-by: bitfaster <12851828+bitfaster@users.noreply.github.com>
Contributor
Author
Done in d02e3a8. Added |
Copilot
AI
changed the title
Add IAsyncAlternateLookup support to ConcurrentLfu
Add IAsyncAlternateLookup support to ConcurrentLfu and ConcurrentTLfu
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
IAsyncAlternateLookupsupport toConcurrentLfuandConcurrentTLfu, mirroring the existing implementation onConcurrentLru.Core changes
ConcurrentLfuCore.cs:AlternateLookup<TAlternateKey>now implements bothIAlternateLookupandIAsyncAlternateLookupin a single struct. AddsGetOrAddAsync,GetOrAddAsync<TArg>, and a privateGetOrAddAsyncSlowhelper. SinceTAlternateKey allows ref struct, the public methods are non-async wrappers that capture the ref struct before delegating to the async slow path via a plainKkey.ConcurrentLfu.cs: ExposesGetAsyncAlternateLookup<TAlternateKey>()andTryGetAsyncAlternateLookup<TAlternateKey>().ConcurrentTLfu.cs: ExposesGetAsyncAlternateLookup<TAlternateKey>()andTryGetAsyncAlternateLookup<TAlternateKey>(), delegating to the inner core, matchingConcurrentLfu.Tests
ConcurrentLfuAsyncAlternateLookupTests.cs(new): unit tests for comparer compatibility, andGetOrAddAsync/GetOrAddAsync<TArg>miss+hit behaviour.ConcurrentTLfuTests.cs: unit tests forGetAsyncAlternateLookupandTryGetAsyncAlternateLookupcovering compatible and incompatible comparer cases.ConcurrentLfuSoakTests.cs: two new concurrent soak tests forGetOrAddAsyncandGetOrAddAsync<TArg>usingReadOnlySpan<char>keys.Usage
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.