RedisFlow.RateLimiting
1.0.0
dotnet add package RedisFlow.RateLimiting --version 1.0.0
NuGet\Install-Package RedisFlow.RateLimiting -Version 1.0.0
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="RedisFlow.RateLimiting" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RedisFlow.RateLimiting" Version="1.0.0" />
<PackageReference Include="RedisFlow.RateLimiting" />
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 RedisFlow.RateLimiting --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RedisFlow.RateLimiting, 1.0.0"
#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 RedisFlow.RateLimiting@1.0.0
#: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=RedisFlow.RateLimiting&version=1.0.0
#tool nuget:?package=RedisFlow.RateLimiting&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AspNetCore.RedisRateLimiter
A production-grade, Redis-backed API rate limiting middleware for ASP.NET Core.
Features
- Atomic operations — Uses Redis Lua scripts to prevent race conditions
- Sliding window algorithm for accurate request counting
- Configurable — Set limits, time windows, and client ID extraction strategies
- Standard headers — Returns
X-RateLimit-Limit,X-RateLimit-Remaining, andRetry-After - Fail-open — Gracefully allows requests if Redis is unavailable
Quick Start
// Program.cs
builder.Services.AddRedisRateLimiting("localhost:6379", options =>
{
options.PermitLimit = 100;
options.Window = TimeSpan.FromMinutes(1);
options.ClientIdExtractor = ctx =>
ctx.Request.Headers["X-API-Key"].FirstOrDefault() ?? "anonymous";
});
var app = builder.Build();
app.UseRedisRateLimiting();
Headers
The middleware automatically attaches the following headers to every response for observability:
X-RateLimit-Limit: The maximum number of requests allowed in the window.X-RateLimit-Remaining: The number of requests remaining in the current window.Retry-After: (Only on 429) The number of seconds to wait before retrying.X-RateLimit-Reset: (Only on 429) Same asRetry-After, for compatibility with other standards.
Advanced Configuration
You can customize the rate limiting behavior via RateLimiterOptions:
builder.Services.AddRedisRateLimiting("localhost:6379", options =>
{
// The maximum requests allowed in the window
options.PermitLimit = 50;
// The sliding window duration
options.Window = TimeSpan.FromSeconds(30);
// Prefix for Redis keys to avoid collisions
options.RedisKeyPrefix = "myapp:rl:";
// Custom client identifier extraction (e.g., from a header or claim)
options.ClientIdExtractor = context =>
context.User.Identity?.Name ?? "anonymous";
// Custom rejection message
options.RateLimitExceededMessage = "{\"msg\": \"Slow down!\"}";
});
Resilience
The library is designed with a fail-open strategy. If the Redis server is unreachable or a network exception occurs, the middleware will catch the error and allow the request to proceed to ensure your API remains available.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- StackExchange.Redis (>= 2.12.14)
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 |
|---|---|---|
| 1.0.0 | 109 | 4/16/2026 |