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

Implement optional back population on get operations #292

Merged
merged 4 commits into from
Aug 4, 2024

Conversation

wazzamatazz
Copy link
Contributor

@wazzamatazz wazzamatazz commented Aug 4, 2024

Fixes #291.

This PR adds a new overload for ICacheStack.GetAsync: ValueTask<CacheEntry<T>?> GetAsync<T>(string cacheKey, bool backPopulate).

Specifying false for the backPopulate parameter is equivalent to calling the existing GetAsync<T>(string) overload. Specifying true will use the existing GetWithLayerIndexAsync method in CacheStack to determine if back population is required and, if so, runs back population using the same technique as GetOrSetAsync<T> by assigning the value task returned by BackPopulateCacheAsync to a discard variable.

I've also added unit tests to verify that back population does or does not happen as expected based on the existing tests for GetOrSetAsync.

Adds a `GetAsync<T>(string, bool)` overload to `ICacheStack` that allows the caller to specify if the cache entry should be back-populated to higher cache layers if it is resolved using a lower layer.
@Turnerj Turnerj merged commit e902eaa into TurnerSoftware:main Aug 4, 2024
6 checks passed
@wazzamatazz wazzamatazz deleted the backpopulate-get branch August 5, 2024 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow backfill on get operations
2 participants