ASP.NET Core IDistributedCache Provider for NCache in Web Farms

The older ASP.NET framework provided ASP.NET Cache that was stand-alone and therefore didn’t meet the needs of multi-server environments. It also didn’t allow any “custom” third-party cache providers to plug-in so you were stuck with its built-in stand-alone InProc implementation.

Now, the new ASP.NET Core has fixed that problem and by introducing IDistributedCache interface to handle caching in a multi-server environment (e.g. load balanced web farms). Here is what IDistributedCache interface looks like (please note that each of these methods also has an Async overload).

Additionally, ASP.NET Core IDistributedCache interface is pluggable by design and allows you to use third-party providers of your choice. NCache has implemented a provider for IDistributedCache that you can plug in to your ASP.NET Core applications seamlessly. This way, you don’t have to change any code specific to NCache.

NCache API Far Richer than IDistributedCache

It gives you a lot of flexibility to program against IDistributedCache interface because you can now plug in any third party distributed cache of your choice. However, that flexibility comes at a cost that IDistributedCache interface is very simple and basic. As a result, you are unable to benefit from some very important distributed caching features.

If you put in a little bit of extra effort up front and use NCache API directly, you benefit greatly from a vast variety of NCache advanced caching features including:

NCache a Better Choice than Redis for .NET Apps

NCache is a much better choice than Redis for .NET apps for the following reasons:

NCache Native .NET: NCache is 100% native .NET and therefore fits into your .NET application stack very nicely. On the other hand, Redis comes from a Linux background and is not a native .NET cache that complicates your overall development, QA, and production environments.

Faster than Redis: NCache is actually faster than Redis. On regular features, NCache and Redis have approximately the same performance. But, NCache has this Client Cache feature that gives NCache a significant performance boost over Redis.

More Features than Redis: NCache offers a variety of very important distributed cache features that Redis does not. This includes (see NCache vs Redis detailed comparison for more details):

Search Cache with SQL Queries

Sync Cache with Database

Managing Data Relationships in the Cache

Data Grouping

Read-through and Write-through

Entity Framework Core Caching

More…

What to Do Next?

NCache comes in the following three editions:

Open Source Edition

Professional Edition

Enterprise Edition

For more details about each edition, see Edition Comparison. Or, chose one of the following options below.