Cookie Consent by Free Privacy Policy Generator IDistributedCache Provider for ASP.NET Core - NCache

IDistributedCache Provider for ASP.NET Core

Enhance Your ASP.NET Apps

The traditional ASP.NET framework relied on the ASP.NET Cache, which was limited to a single server (InProc) and lacked support for multi-server environments. It also didn't allow integration with third-party distributed caches. As a result, developers were forced to rely on inefficient, standalone caching mechanisms.

Microsoft solved these challenges with ASP.NET Core, introducing the IDistributedCache, interface for scalable, multi-server caching solutions. NCache is easy to integrate with IDistributedCache, which gives your ASP.NET Core applications a high-performance, feature-rich caching layer.

 

What is IDistributedCache?

The IDistributedCache interface provides a centralized caching mechanism that works across multiple servers, making it ideal for cloud-native, containerized, and microservice-based architectures. Below is the latest interface definition for .NET 8:

using Microsoft.Extensions.Caching.Distributed;
using System.Threading;
using System.Threading.Tasks;

public interface IDistributedCache
{
    byte[]? Get(string key);
    Task<byte[]?> GetAsync(string key, CancellationToken token = default);
    void Refresh(string key);
    Task RefreshAsync(string key, CancellationToken token = default);
    void Remove(string key);
    Task RemoveAsync(string key, CancellationToken token = default);
    void Set(string key, byte[] value, DistributedCacheEntryOptions options);
    Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions options, CancellationToken token = default);
}
 

Why Choose NCache for IDistributedCache?

Many caching solutions, like MemoryDistributedCache, are limited to a single server, making them unsuitable for applications that need scalability and high availability. NCache, on the other hand, is a true distributed caching solution designed specifically for .NET applications, ensuring better performance and scalability.

Key Benefits of NCache

  • 100% Native .NET - Fully compatible and optimized for .NET applications.
  • High Performance & Scalability - Enables fast data retrieval and supports seamless horizontal scalability.
  • Advanced Caching Features - Supports SQL queries, pub/sub messaging, and cache synchronization.
  • High Availability & Reliability - Ensures data consistency with built-in failover support.
  • Optimized Serialization - Reduces latency and improves performance through efficient serialization.

Seamless NCache Integration with IDistributedCache

Integrating NCache with your ASP.NET Core application is simple. You can plug-in NCache without modifying existing application logic. This allows you to transition smoothly from in-memory caching to a highly available distributed cache.

 

Configure NCache as Your IDistributedCache Provider

To use NCache as your default IDistributedCache provider, simply register it in the ASP.NET Core applications Program.cs file:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddNCacheDistributedCache(options =>
{
    options.CacheName = builder.Configuration["NCache:CacheName"];
});

var app = builder.Build();
app.MapControllers();
app.Run();

Alternatively, you can configure NCache in the appsettings.json file and load settings dynamically:

{
    "NCacheSettings": {
        "CacheName": "myCache",
        "EnableLogs": true,
        "EnableStatistics": true
    }
}

This ensures scalability, fault tolerance, and high availability in production environments.

 

NCache API: Far Richer than IDistributedCache

The IDistributedCache interface provides a basic key-value store, which is useful but quite limited in functionality. NCache goes far beyond by offering an extensive, high-performance caching API that enables powerful, distributed caching for enterprise applications.

Key Advantages of NCache API:

By using the NCache API, organizations can overcome the limitations of IDistributedCache, unlocking enhanced performance, flexibility, and enterprise-grade caching for their .NET applications.

 

Get Started with NCache Today!

Ready to optimize your ASP.NET Core applications with high-performance distributed caching? Explore NCache and take advantage of its powerful features.

© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.