NCache.OSS.RateLimiting 5.3.603

dotnet add package NCache.OSS.RateLimiting --version 5.3.603
                    
NuGet\Install-Package NCache.OSS.RateLimiting -Version 5.3.603
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NCache.OSS.RateLimiting" Version="5.3.603" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NCache.OSS.RateLimiting" Version="5.3.603" />
                    
Directory.Packages.props
<PackageReference Include="NCache.OSS.RateLimiting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NCache.OSS.RateLimiting --version 5.3.603
                    
#r "nuget: NCache.OSS.RateLimiting, 5.3.603"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NCache.OSS.RateLimiting@5.3.603
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NCache.OSS.RateLimiting&version=5.3.603
                    
Install as a Cake Addin
#tool nuget:?package=NCache.OSS.RateLimiting&version=5.3.603
                    
Install as a Cake Tool

NCache RateLimiting Integration

NCache integration for the .NET rate limiting API. This package provides concurrency, fixed window, sliding window and token bucket limiters whose state lives in an NCache cluster, so a limit is enforced across all application instances rather than per process. It plugs into System.Threading.RateLimiting (RateLimiter, RateLimitPartition, PartitionedRateLimiter) and the ASP.NET Core Microsoft.AspNetCore.RateLimiting middleware.

Installation

Install-Package NCache.OSS.RateLimiting

or, using the .NET CLI:

dotnet add package NCache.OSS.RateLimiting

What is Installed

Installing this package adds the following NCache configuration files to your project:

  • client.ncconf — Defines the cache client settings, including the cache name and the list of server nodes the client connects to.
  • config.ncconf — Contains the cache configuration (cache topology, partitions, eviction policy, etc.) used when the cache is created/registered.

Prerequisites

  • .NET 8.0 or higher.
  • An NCache 5.3.603 (or later) server should be up and running, with the target cache already created/registered on it.

Getting Started

Setting up NCache

The servers can be given in code (shown below). If you leave ServerList empty, the client reads them from a client.ncconf in your project; in that case, if NCache is not installed on the current machine, add one and set the cache id to your cache name:

<configuration>
  <ncache-server port="9800" />
  <cache id="defaultCache" enable-client-logs="False" log-level="error">
    <server name="10.0.0.1" />
  </cache>
</configuration>

Change defaultCache to the name of your actual cache, and 10.0.0.1 to the IP/hostname of a node hosting it. Mark the file to be copied to the output directory.

Setting up Package

Register the limiters as named policies of the ASP.NET Core rate limiter, then apply a policy to the endpoints you want to protect:

using Microsoft.AspNetCore.RateLimiting;
using NCache.OSS.RateLimiting;

builder.Services.AddRateLimiter(options =>
{
    options.RejectionStatusCode = StatusCodes.Status429TooManyRequests;

    options.AddNCacheFixedWindowLimiter("orders", limiter =>
    {
        limiter.PermitLimit = 100;
        limiter.Window = TimeSpan.FromMinutes(1);
        limiter.CacheName = "defaultCache";
        limiter.ServerList.Add(new NCache.OSS.RateLimiting.RateLimiterOptions.ServerConfig { Ip = "10.0.0.1", Port = 9800 });
    });
});

var app = builder.Build();
app.UseRateLimiter();

app.MapPost("/order", () => Results.Ok()).RequireRateLimiting("orders");

Because the counters are kept in NCache, every instance behind the load balancer draws from the same 100 permits per minute.

The same limiters are available as plain RateLimiter instances and as partitions (for example one limit per user or per IP):

var limiter = new FixedWindowRateLimiter<string>("orders", new FixedWindowLimiterOptions
{
    PermitLimit = 100,
    Window = TimeSpan.FromMinutes(1),
    CacheName = "defaultCache"
});

PartitionedRateLimiter<HttpContext> partitioned = PartitionedRateLimiter.Create<HttpContext, string>(context =>
    NCache.OSS.RateLimiting.RateLimitPartition.GetFixedWindowRateLimiter(
        context.User.Identity?.Name ?? "anonymous",
        key => new FixedWindowLimiterOptions
        {
            PermitLimit = 20,
            Window = TimeSpan.FromMinutes(1),
            CacheName = "defaultCache"
        }));

Configuration

Every limiter's options derive from RateLimiterOptions, which carries the connection settings.

Property Description
CacheName Name of the NCache cache that holds the limiter state. Required.
ServerList NCache server nodes to connect to (Ip, and Port which defaults to 9800). If empty, client.ncconf is used.
Port Default NCache client port (9800).

Each limiter adds its own settings:

Limiter Registration Options
Concurrency AddNCacheConcurrencyLimiter PermitLimit, QueueLimit, TryDequeuePeriod (1 s), ExpectedRequestTimeout (60 s), LockTimeout (10 s)
Fixed window AddNCacheFixedWindowLimiter PermitLimit, Window, LockTimeout (5 s)
Sliding window AddNCacheSlidingWindowLimiter PermitLimit, Window, LockTimeout (5 s)
Token bucket AddNCacheTokenBucketLimiter TokenLimit, TokensPerPeriod, ReplenishmentPeriod, LockTimeout (5 s)

The package provides:

  • Concurrency limiter — bounds the number of in-flight requests; excess requests wait in a first-in-first-out queue shared by all nodes and are rejected once QueueLimit is reached.
  • Fixed window limiter — allows up to PermitLimit requests per window, resetting the count when the window elapses.
  • Sliding window limiter — tracks individual request timestamps and slides the window continuously, avoiding the burst at a fixed window's boundary.
  • Token bucket limiter — refills tokens at a steady rate, allowing short bursts up to TokenLimit while enforcing a long-run average.
  • AddNCache...Limiter extension methods for the ASP.NET Core middleware, and RateLimitPartition.Get...RateLimiter helpers for partitioned limiters.

State keys expire in NCache on their own, so a process that crashes while holding a lease does not block the limit forever.

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 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.603 125 10/29/2026
5.3.6.1 151 8/21/2026