Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Is GetOrCreate thread-safe? #359
Do you mean to ask if it guarantees nothing else will modify the same cache key? No, it doesn't. Other threads may attempt to create an entry with the same key at the same time. Only the low level cache operations are thread safe such as Get or Set, and only in that they will not corrupt the cache. When multiple threads are operating on one key there's no guarantee which will win.
even though this issue is closed, I think it's it should be reopened.
moreover, AFAIK the .net framework equivalent was thread safe
relevant discussion on stack overflow
Maybe it's best if i give an example.
you would find that you get different results for
you run the same code (with minor adjustments) with