Caching resources in memory
Caching items in memory requires RAM to be allocated so that they can be stored and retrieved efficiently. Storing frequently accessed resources in memory greatly improves the performance of applications.
A typical application that benefits from caching is a website. A traditional website will consist of HTML pages that define the structure of the visual web page that’s displayed to end users, CSS, which styles the page and makes it look nice, and JavaScript, which makes websites dynamic and interactive.
Many pages of a website can use the same resources, such as data, images, sounds, files, and objects. Caching – temporarily storing some item so that it can be retrieved efficiently – can be done with a database, filesystem, or memory.
In this section, we will learn how to store items in memory. Microsoft recommends the use of their Microsoft.Extensions.Caching.Memory
NuGet package for caching items in memory. Therefore...