IDistributed Cache
Provider for ASP.NET Core applicationsThe 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).
namespace Microsoft.Extensions.Caching.Distributed
{
public interface IDistributedCache
{
// These methods also have overloads for “Async”
byte[] Get(string key);
void Refresh(string key);
void Remove(string key);
// Absolute expiration & sliding expirations possible
void Set(string key, byte[] value,
DistributedCacheEntryOptions options);
}
}
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.
IDistributedCache
ProviderAnd, here is how to configure NCache as your IDistributed Cache provider in your ASP.NET Core Startup class:
public class Startup {
...
public void ConfigureServices (IServiceCollection services) {
...
services.AddNCacheDistributedCache();
...
}
...
}
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:
Learn more about all the NCache features that are useful to you.
NCache is a much better choice than Redis for .NET apps for the following reasons:
NCache comes in the following three editions:
NCache Open Source
NCache Professional
NCache Enterprise
For more details about each edition, see Edition Comparison. Or, chose one of the following options below.
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.