IDistributedCache in ASP.NET Core
IDistributedCache is the ASP.NET Core abstraction for distributed caching that enables applications to store and retrieve data from a centralized cache shared across multiple application instances. Unlike in-memory caching, distributed caching allows cached data to remain accessible regardless of which application server processes a request, making it suitable for load-balanced and cloud-hosted environments.
NCache implements the IDistributedCache interface, allowing ASP.NET Core applications to use a distributed cache through the standard caching APIs provided by the framework. This integration enables developers to leverage distributed caching while continuing to work with the familiar ASP.NET Core caching model.
To get started with NCache and IDistributedCache, you first need to configure NCache as the distributed cache provider for your ASP.NET Core application. Once configured, you can use the standard IDistributedCache APIs to store, retrieve, and manage cached data. This section covers both the configuration of NCache as an ASP.NET Core IDistributedCache provider and the use of the IDistributedCache API for distributed caching operations.
Why Use IDistributedCache?
Distributed caching helps improve application performance by reducing repeated access to backend data sources such as databases, web services, and external systems. By storing frequently accessed data in memory, applications can serve requests more efficiently and reduce overall system load.
Key benefits include:
- Improved application response times
- Reduced database and backend service load
- Shared cache access across multiple application instances
- Better scalability for high-traffic applications
- Consistent access to cached data in distributed environments
In This Section
Configure IDistributedCache in ASP.NET Core
Learn how to configure NCache as an ASP.NET Core IDistributedCache provider using Startup.cs or appsettings.json.
Using IDistributedCache in ASP.NET Core
Learn how to use the ASP.NET Core IDistributedCache API with NCache to store, retrieve, and manage cached data.