Skip to content

Commit 8c0f108

Browse files
mohsinnasirguardrex
authored andcommitted
Add NCache coverage to the Distributed Caching topic (dotnet#16635)
1 parent 620238e commit 8c0f108

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

aspnetcore/performance/caching/distributed.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ description: Learn how to use an ASP.NET Core distributed cache to improve app p
55
monikerRange: '>= aspnetcore-2.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 08/27/2019
8+
ms.date: 01/22/2020
99
uid: performance/caching/distributed
1010
---
1111
# Distributed caching in ASP.NET Core
1212

13-
By [Luke Latham](https://github.com/guardrex) and [Steve Smith](https://ardalis.com/)
13+
By [Luke Latham](https://github.com/guardrex), [Mohsin Nasir](https://github.com/mohsinnasir), and [Steve Smith](https://ardalis.com/)
1414

1515
A distributed cache is a cache shared by multiple app servers, typically maintained as an external service to the app servers that access it. A distributed cache can improve the performance and scalability of an ASP.NET Core app, especially when the app is hosted by a cloud service or a server farm.
1616

@@ -34,6 +34,8 @@ To use a SQL Server distributed cache, add a package reference to the [Microsoft
3434

3535
To use a Redis distributed cache, add a package reference to the [Microsoft.Extensions.Caching.StackExchangeRedis](https://www.nuget.org/packages/Microsoft.Extensions.Caching.StackExchangeRedis) package.
3636

37+
To use NCache distributed cache, add a package reference to the [NCache.Microsoft.Extensions.Caching.OpenSource](https://www.nuget.org/packages/NCache.Microsoft.Extensions.Caching.OpenSource) package.
38+
3739
::: moniker-end
3840

3941
::: moniker range="= aspnetcore-2.2"
@@ -42,6 +44,8 @@ To use a SQL Server distributed cache, reference the [Microsoft.AspNetCore.App m
4244

4345
To use a Redis distributed cache, reference the [Microsoft.AspNetCore.App metapackage](xref:fundamentals/metapackage-app) and add a package reference to the [Microsoft.Extensions.Caching.StackExchangeRedis](https://www.nuget.org/packages/Microsoft.Extensions.Caching.StackExchangeRedis) package. The Redis package isn't included in the `Microsoft.AspNetCore.App` package, so you must reference the Redis package separately in your project file.
4446

47+
To use NCache distributed cache, reference the [Microsoft.AspNetCore.App metapackage](xref:fundamentals/metapackage-app) and add a package reference to the [NCache.Microsoft.Extensions.Caching.OpenSource](https://www.nuget.org/packages/NCache.Microsoft.Extensions.Caching.OpenSource) package. The NCache package isn't included in the `Microsoft.AspNetCore.App` package, so you must reference the NCache package separately in your project file.
48+
4549
::: moniker-end
4650

4751
::: moniker range="< aspnetcore-2.2"
@@ -50,6 +54,8 @@ To use a SQL Server distributed cache, reference the [Microsoft.AspNetCore.App m
5054

5155
To use a Redis distributed cache, reference the [Microsoft.AspNetCore.App metapackage](xref:fundamentals/metapackage-app) and add a package reference to the [Microsoft.Extensions.Caching.Redis](https://www.nuget.org/packages/Microsoft.Extensions.Caching.Redis) package. The Redis package isn't included in the `Microsoft.AspNetCore.App` package, so you must reference the Redis package separately in your project file.
5256

57+
To use NCache distributed cache, reference the [Microsoft.AspNetCore.App metapackage](xref:fundamentals/metapackage-app) and add a package reference to the [NCache.Microsoft.Extensions.Caching.OpenSource](https://www.nuget.org/packages/NCache.Microsoft.Extensions.Caching.OpenSource) package. The NCache package isn't included in the `Microsoft.AspNetCore.App` package, so you must reference the NCache package separately in your project file.
58+
5359
::: moniker-end
5460

5561
## IDistributedCache interface
@@ -68,6 +74,7 @@ Register an implementation of <xref:Microsoft.Extensions.Caching.Distributed.IDi
6874
* [Distributed Memory Cache](#distributed-memory-cache)
6975
* [Distributed SQL Server cache](#distributed-sql-server-cache)
7076
* [Distributed Redis cache](#distributed-redis-cache)
77+
* [Distributed NCache cache](#distributed-ncache-cache)
7178

7279
### Distributed Memory Cache
7380

@@ -168,8 +175,29 @@ services.AddDistributedRedisCache(options =>
168175

169176
To install Redis on your local machine:
170177

171-
* Install the [Chocolatey Redis package](https://chocolatey.org/packages/redis-64/).
172-
* Run `redis-server` from a command prompt.
178+
1. Install the [Chocolatey Redis package](https://chocolatey.org/packages/redis-64/).
179+
1. Run `redis-server` from a command prompt.
180+
181+
### Distributed NCache Cache
182+
183+
[NCache](https://github.com/Alachisoft/NCache) is an open source in-memory distributed cache developed natively in .NET and .NET Core. NCache works both locally and configured as a distributed cache cluster for an ASP.NET Core app running in Azure or on other hosting platforms.
184+
185+
To install and configure NCache on your local machine, see [NCache Getting Started Guide for Windows](https://www.alachisoft.com/resources/docs/ncache-oss/getting-started-guide-windows/).
186+
187+
To configure NCache:
188+
189+
1. Install [NCache open source NuGet](https://www.nuget.org/packages/Alachisoft.NCache.OpenSource.SDK/).
190+
1. Configure the cache cluster in [client.ncconf](https://www.alachisoft.com/resources/docs/ncache-oss/admin-guide/client-config.html).
191+
1. Add the following code to `Startup.ConfigureServices`:
192+
193+
```csharp
194+
services.AddNCacheDistributedCache(configuration =>
195+
{
196+
configuration.CacheName = "demoClusteredCache";
197+
configuration.EnableLogs = true;
198+
configuration.ExceptionsEnabled = true;
199+
});
200+
```
173201

174202
## Use the distributed cache
175203

0 commit comments

Comments
 (0)