Closed Daniel15 closed 2 years ago
The only shared state are the underlying HTTP / cache systems. @SobanMahmood are these from the standard libraries, and if so can you double-check if there's any mention of thread-safety? I'd assume it's all good.
@Daniel15, so library is thread safe with default components, and for your use case, this should work fine with the default cache implementation used in the library.
So here are some details. The HttpClient and MemoryCache are used in this library. MemoryCache is the default cache being used and is reported to be thread-safe. There is also option for not using Cache, so library will still be thread-safe in that case.
One can implement their own ICache implementation, but then thread safety needs to be ensured by that implementation.
Regarding the HttpClient
, our usage of it is thread safe. The thread-safe methods for HttpClient
can be checked here.
If some other cache is used for ICache
interface, then thread safety depends upon that cache implementation.
Thanks for the details! This would be useful to document in the readme both in the GitHub repo and on NuGet :)
Is this library threadsafe? If I want to use it in a web app, can I have one singleton instance of the client and use it across multiple requests concurrently?