Microsoft’s ASP.NET Core has become a popular way to build high-performance, modern web applications that can run on Windows, Linux, or MacOS. An important way to ensure high performance and reliability in applications that experience high volumes of requests is caching frequently used data.
LazyCache is a simple in-memory caching service that is both easy to use and thread safe. “Lazy” refers to the fact that LazyCache will never execute your cacheable delegates more than once for each “cache miss,“ i.e., whenever the data requested is not found in the cache. In other words, laziness reduces computational overhead.
This article talks about how we can work with LazyCache in ASP.NET Core 5.0. To work with the code examples illustrated in this article, you should have Visual Studio 2019 installed in your system. If you don’t already have a copy, you can download Visual Studio 2019 here.