NCache.RateLimiting
5.3.800
dotnet add package NCache.RateLimiting --version 5.3.800
NuGet\Install-Package NCache.RateLimiting -Version 5.3.800
<PackageReference Include="NCache.RateLimiting" Version="5.3.800" />
<PackageVersion Include="NCache.RateLimiting" Version="5.3.800" />
<PackageReference Include="NCache.RateLimiting" />
paket add NCache.RateLimiting --version 5.3.800
#r "nuget: NCache.RateLimiting, 5.3.800"
#:package NCache.RateLimiting@5.3.800
#addin nuget:?package=NCache.RateLimiting&version=5.3.800
#tool nuget:?package=NCache.RateLimiting&version=5.3.800
NCache.RateLimiting
NCache Rate Limiting Provider for ASP.NET Core applications. This package lets you use NCache as the backing store for ASP.NET Core Rate Limiting, allowing rate limit state (permits, leases, queues, windows) to be shared across multiple application instances instead of being tracked in memory on individual servers. It provides concurrency, fixed window, sliding window, and token bucket limiters.
Installation
Install-Package NCache.RateLimiting
or, using the .NET CLI:
dotnet add package NCache.RateLimiting
Prerequisites
- An ASP.NET Core application targeting .NET 7, .NET 8 or .NET 10. (.NET 9 applications use the .NET 8 build.)
- An NCache 5.3.800 (or later) server should be up and running, with the target cache already created/registered on it.
Getting Started
Setting up NCache
Starting with NCache SDK 5.3.800, the application names only the cache; the server it connects to is read from the application's own configuration file, with one entry per cache name.
.NET (appsettings.json):
{
"ncache": {
"YourCacheName": {
"server": "10.0.0.1",
"port": 9800
}
}
}
.NET Framework (App.config / Web.config):
<configuration>
<configSections>
<section name="ncache" type="Alachisoft.NCache.Client.NCacheSection, Alachisoft.NCache.Client" />
</configSections>
<ncache>
<caches>
<add name="YourCacheName" server="10.0.0.1" port="9800" />
</caches>
</ncache>
</configuration>
Replace YourCacheName with the name of your cache and 10.0.0.1 with the IP/hostname of a node hosting it. Multiple servers can be listed as a comma-separated value (for example "10.0.0.1,10.0.0.2").
Note
The
ncachesection is validated strictly: an unknown setting or an invalid port is reported as a configuration error naming the cache and the setting. Use the setting names shown above (server,port, ...), not names such asCacheNameorServerList.
Setting up Package
- Register ASP.NET Core Rate Limiting and add an NCache-backed policy:
builder.Services.AddRateLimiter(options =>
{
options.AddNCacheConcurrencyLimiter("my-policy", limiter =>
{
limiter.PermitLimit = 10;
limiter.QueueLimit = 5;
limiter.CacheName = "defaultCache";
});
});
- Enable Rate Limiting middleware:
app.UseRateLimiter();
- Apply a policy to endpoints using ASP.NET Core's standard
[EnableRateLimiting("my-policy")]attribute or.RequireRateLimiting("my-policy")extension method.
Configuration
Using appsettings.json:
{
"RateLimiting": {
"Concurrency": {
"PermitLimit": 10,
"QueueLimit": 5,
"LockTimeout": "00:00:10",
"CacheName": "defaultCache",
"ServerList": [
{
"Ip": "20.200.20.29"
}
]
}
}
}
Register the policy:
builder.Services.AddRateLimiter(options =>
{
options.AddNCacheConcurrencyLimiter(
"my-policy",
builder.Configuration.GetSection("RateLimiting:Concurrency"));
});
Or configure programmatically:
builder.Services.AddRateLimiter(options =>
{
options.AddNCacheConcurrencyLimiter("my-policy", limiter =>
{
limiter.PermitLimit = 10;
limiter.QueueLimit = 5;
limiter.CacheName = "defaultCache";
limiter.ServerList = new List<RateLimiterOptions.ServerConfig>
{
new RateLimiterOptions.ServerConfig
{
Ip = "20.200.20.29"
}
};
});
});
The same code-based and configuration-based pattern applies to AddNCacheFixedWindowLimiter, AddNCacheTokenBucketLimiter, and AddNCacheSlidingWindowLimiter, each with their own limiter-specific settings (Window, TokenLimit, TokensPerPeriod, ReplenishmentPeriod, etc.). Adjust the cache name, server list, and limiter settings as needed for your environment.
Note
UseRateLimiter()is still required.AddNCacheXxxLimiterregisters only the policy backing store used by ASP.NET Core Rate Limiting.
Resources
Technical Support
Alachisoft provides various technical support resources.
Visit the Alachisoft Support Center to select a support resource appropriate for your issue.
To request additional features or report a documentation discrepancy, contact support@alachisoft.com.
License
Copyright © 2026 Alachisoft. All rights reserved.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Alachisoft.NCache.SDK (>= 5.3.800)
- System.Threading.RateLimiting (>= 10.0.12)
-
net7.0
- Alachisoft.NCache.SDK (>= 5.3.800)
- System.Threading.RateLimiting (>= 10.0.12)
-
net8.0
- Alachisoft.NCache.SDK (>= 5.3.800)
- System.Threading.RateLimiting (>= 10.0.12)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.