DistributedCacheAspNetCoreRedis
DistributedCacheAspNetCoreRedis copied to clipboard
⚡️ Distributed caching on .NET with IDistributedCache
Distributed Caching on .NET with IDistributedCache
Intro 👋
This project leverages the IDistributedCache that's shipped as part of .NET/.NET Core SDKs to achieve distributed caching in a microservices environment. If you are looking for a monolithing caching approach, then, my other project would be more suitable for you.
I've also blogged this with a full explanation of how this is achieved.
Note: I have recently migrated this project to .NET 6 and also a docker-compose.yaml for better dev experience 🎉 You can still access the old version from the .NET 5 branch in this repo.
Architecture 🏗

- User requests a user object.
- App server checks if we already have a user in the cache and return the object if present.
- App server makes a HTTP call to retrieve the list of users.
- Users service returns the users list to the app server.
- App server sends the users list to the distributed (Redis) cache.
- App server gets the cached version until it expires (TTL).
- User gets the cached user object.
Usage 🚀
Open up a terminal and run the following:
docker-compose up and dotnet run
Questions? Bugs? Suggestions for Improvement? ❓
Having any issues or troubles getting started? Get in touch with me
Support 🎗
Has this Project helped you learn something new? or helped you at work? Please consider giving a ⭐️ if this project helped you!
Share it! ❤️
Please share this Repository within your developer community, if you think that this would make a difference! Cheers.
Contributing ✍️
PRs are welcome! Thank you