NCache.OSS.RateLimiting
5.3.6.1
dotnet add package NCache.OSS.RateLimiting --version 5.3.6.1
NuGet\Install-Package NCache.OSS.RateLimiting -Version 5.3.6.1
<PackageReference Include="NCache.OSS.RateLimiting" Version="5.3.6.1" />
<PackageVersion Include="NCache.OSS.RateLimiting" Version="5.3.6.1" />
<PackageReference Include="NCache.OSS.RateLimiting" />
paket add NCache.OSS.RateLimiting --version 5.3.6.1
#r "nuget: NCache.OSS.RateLimiting, 5.3.6.1"
#:package NCache.OSS.RateLimiting@5.3.6.1
#addin nuget:?package=NCache.OSS.RateLimiting&version=5.3.6.1
#tool nuget:?package=NCache.OSS.RateLimiting&version=5.3.6.1
NCache.OSS.RateLimiting
An NCache implementation of the RateLimiting API, providing concurrency, fixed window, sliding window, and token bucket rate limiters backed by an NCache cluster.
This package plugs into the System.Threading.RateLimiting abstractions (RateLimiter, RateLimitPartition, PartitionedRateLimiter) as well as ASP.NET Core's Microsoft.AspNetCore.RateLimiting middleware, so it can be used as a drop-in rate limiting provider anywhere those types are expected.
Features
- Concurrency Limiter — bounds the number of concurrent in-flight requests, queuing excess requests in strict, cross-node FIFO order and rejecting once the queue is full.
- Fixed Window Limiter — allows up to
Nrequests per fixed time window, resetting the count when the window elapses. - Sliding Window Limiter — tracks individual request timestamps and continuously slides the evaluation window forward, avoiding the burst-at-boundary behavior of fixed windows.
- Token Bucket Limiter — a bucket of tokens that refills at a steady rate, allowing short bursts up to the bucket's capacity while enforcing a long-run average rate.
- State keys are auto-expired in NCache as a safety net against processes that crash while holding a lease.
Installation
dotnet add package NCache.OSS.RateLimiting
Requirements
- .NET 8.0 or higher
- An NCache client connection (
Alachisoft.NCache.Client) to a running NCache cache/cluster - References
Alachisoft.NCache.Opensource.SDKandSystem.Threading.RateLimiting
Usage
Setting up rate limiting
using Microsoft.AspNetCore.RateLimiting;
using NCache.OSS.RateLimiting;
builder.Services.AddRateLimiter(options =>
{
options.AddNCacheConcurrencyLimiter("my-policy", limiter =>
{
limiter.PermitLimit = 10;
limiter.QueueLimit = 5;
limiter.CacheName = "myCache";
});
});
AddRateLimiter accepts any combination of the four AddNCacheXxxLimiter policy registrations below, so it can configure any of the four primitives shown here.
Concurrency Limiter
options.AddNCacheConcurrencyLimiter("my-resource-name", limiter =>
{
limiter.PermitLimit = 10;
limiter.QueueLimit = 5;
limiter.CacheName = "myCache";
});
// or: var concurrencyLimiter = new ConcurrencyRateLimiter<string>("my-resource-name", options);
Fixed Window Limiter
options.AddNCacheFixedWindowLimiter("my-resource-name", limiter =>
{
limiter.PermitLimit = 100;
limiter.Window = TimeSpan.FromMinutes(1);
limiter.CacheName = "myCache";
});
// or: var fixedWindowLimiter = new FixedWindowRateLimiter<string>("my-resource-name", options);
Sliding Window Limiter
options.AddNCacheSlidingWindowLimiter("my-resource-name", limiter =>
{
limiter.PermitLimit = 100;
limiter.Window = TimeSpan.FromMinutes(1);
limiter.CacheName = "myCache";
});
// or: var slidingWindowLimiter = new NCacheSlidingWindowRateLimiter<string>("my-resource-name", options);
Token Bucket Limiter
options.AddNCacheTokenBucketLimiter("my-resource-name", limiter =>
{
limiter.TokenLimit = 100;
limiter.TokensPerPeriod = 10;
limiter.ReplenishmentPeriod = TimeSpan.FromSeconds(10);
limiter.CacheName = "myCache";
});
// or: var tokenBucketLimiter = new TokenBucketRateLimiting<string>("my-resource-name", options);
Important
If NCache is not installed on the machine, you must ensure that Client. ncconf and Config.ncconf contain all required configuration information.
Documentation
A guide to NCache API can be found at:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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. |
-
net8.0
- Alachisoft.NCache.Opensource.SDK (>= 5.3.6.2)
- System.Threading.RateLimiting (>= 10.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.3.6.1 | 73 | 8/21/2026 |