A short practical guide showing how to use IMemoryCache with .NET 6 minimal API endpoints. The example demonstrates injecting MemoryCache into a MapGet endpoint, checking for a cached value by key, returning it if found, or performing a fake database lookup and storing the result with a 10-second expiry if not found. The full working code is provided inline.

2m read timeFrom nodogmablog.bryanhogan.net
Post cover image
1 Impression