Skip to content

Conversation

@technicianted
Copy link

This PR adds a new method GetOrSet to handle the case where we run into a race when multiple threads do "if not found then set" sequence. Without using GetOrSet, callers will have to use global locks, then perform 1-2 cache operations (Add followed by Get if already exists) which would be redundant and inefficient.

There was a similar PR #82 but it tried to do it using a closure instead of a simple value. This PR takes a much simpler approach to avoid potential long held locks by external code.

Repository owner deleted a comment from pablodz Jan 8, 2024
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.

1 participant