To avoid having to make redundant calls to components or systems outside of your application, it may be beneficial to cache data.
The caching APIs within .NET Core should be used for most scenarios.
The primary scenarios are in-memory caching and distributed caching.
Depending on the size/amount of data and if the data needs to be shared/distributed will help determine if in-memory caching or distributed caching should be used.
It is not recommended to use distributed caching for small data sets. Distributed caching works well for data sets with large numbers of records.
For in-memory caching in .NET Core use: Microsoft.Extensions.Caching.Memory/IMemoryCache
For distributed caching in .NET Core use: Microsoft.Extensions.Caching.Distributed/IDistributedCache
Other than the interface name and registration in Startup.cs, using in-memory cache and distributed cache interfaces are nearly identical.
If an application needs to use distributed caching, Azure Redis Cache should be used. Azure Cache for Redis is a fully managed, open source–compatible in-memory data store to power fast, scalable applications.
To easily consume Azure Redis Cache functionality, connect to the NuGet feed in the Artifacts section of Azure DevOps and download the shared client library “Shared.DistributedCaching”.
For more information about in-memory caching, visit https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory
For more information about distributed caching, visit https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed