-
-
Notifications
You must be signed in to change notification settings - Fork 456
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
GetOrAdd Concurrency Problem #268
Comments
There is currently no locking mechanism on keys, no. That being said, I'm planning to add lock helpers and some functionality in the future which will help with that. |
Any suggestions for a short-term workaround? Or a timeline on adding the locking semantics? |
As long as you don't use distributed caching, it is relatively easy. |
Just to support with missing feature with test case:
|
@MichaCo shouldn't it be |
In case anyone else comes upon this issue and wants a workaround, I've built a set of extension methods that provide synchronized behavior for Hope this helps someone....
|
I'm finding that, when multiple threads call
.GetOrAdd()
on the same emptyICacheManager<T>
instance with the same key value, that thevalueFactory
func is called multiple times, indicating an apparent lack of any synchronization within.GetOrAdd()
.Is this the correct behavior? My expectation is that the first thread to call
.GetOrAdd()
when the given key does not exist in cache would block other callers asking for the same key until thevalueFactory
func is complete and then return that newly cached item.The text was updated successfully, but these errors were encountered: