-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Replace Values with KeyValuePair enumerator in MemoryCache #53762
Conversation
Changed code to use KeyValuePair enumerator
Update MemoryCache to use KeyValuePair enumerator from concurrent dictionary
Tagging subscribers to this area: @eerhardt, @maryamariyan, @michaelgsharp Issue DetailsConcurrentDictionary.Values will lock all the locks in the MemoryCache internal _entries ConcurrentDictionary .
|
Related issue: |
@martincostello @eerhardt any other comments? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @ezgambac !
ConcurrentDictionary.Values will lock all the locks in the MemoryCache internal _entries ConcurrentDictionary .
However, using regular dictionary enumerator which returns a KeyValuePair<TKey, TValue> does not cause locking.
This is important in heavy throughput scenarios as accessing .Values could reduce write throughput for the MemoryCache.