Technology, Software Development, Dotnet Core, API, Rate Limiting.
$"token_bucket_{context.Request.Path}"; var cache = context.RequestServices.GetRequiredService<IDistributedCache>(); var tokenCount = Convert.ToInt32(await cache.GetStringAsync(key)) - 1; if (tokenCount < 0) { context.Response.StatusCode = 429; await context.Response.WriteAsync("Rate limit