This project leverages the IMemoryCache that's shipped as part of .NET/.NET Core SDKs to achieve in-memory caching specifically in monolithic environments. If you are looking for a distributed caching approach, then, my other project would be more suitable for you.
I have also blogged with a full explanation on how this is achieved.
- User A makes a request to our web service
- In-memory cache doesn’t have a value in place, it enters in to lock state and makes a request to the Users Service
- User B makes a request to our web service and waits till the lock is released
- This way, we can reduce the number of calls being made to the external web service. returns the response to our web service and the value is cached
- Lock is released, User A gets the response
- User B enters the lock and the cache provides the value (as long it’s not expired)
- User B gets the response
Open up in your favorte editor and do a dotnet run
at the root of the project.
Having any issues or troubles getting started? Get in touch with me
Has this Project helped you learn something new? or helped you at work? Please consider giving a ⭐️ if this project helped you!
Please share this Repository within your developer community, if you think that this would make a difference! Cheers.
PRs are welcome! Thank you