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

Wait for GetOrAddAsync factory to return before reading from AbsoluteExpirationRelativeToNow #160

Conversation

allanrodriguez
Copy link
Contributor

Fixes #148.

  • In GetOrAddAsync, addItemFactory is now awaited before SetAbsoluteExpirationFromRelative is called. This eliminates the race condition where SetAbsoluteExpirationFromRelative reads from ICacheEntry.AbsoluteExpirationRelativeToNow before it is set to, in cases where AbsoluteExpirationRelativeToNow is set after a long-running task in the factory completes.
  • Added unit tests.

…ative

allows AbsoluteExpiration to be set properly when factories are long-running and a relative expiration is specified

fixes alastairtree#148
@alastairtree alastairtree merged commit 32be755 into alastairtree:master Sep 1, 2021
@alastairtree
Copy link
Owner

Awesome thanks

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.

SetAbsoluteExpirationFromRelative called before async Task execution
2 participants