-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This library was created in order to provide a basic in-memory throttle for a total number of requestsPerPeriod / periodInMinutes
, throttled by unique caller identities (a supplied token for example).
The expiration time window is sliding so that the total requests over the specified period are counted from the current minute and the previous periodInMinutes
.
Please see the sample file for a demo of it's basic usage.
It should be noted that making a call to IsThrottled
when you have not reached the throttle limit, counts towards the current total of requests you have made. Therefore, the expected usage for the code would be something like:
if (!throttlingService.IsThrottled(identity))`
{
// Perform the action which is to be protected by throttling.
}
When throttled, the service will not continue to increase the number of requests when calling IsThrottled
, so you can retry as often as is sensible in your app.
Obviously, if the app crashes, is restarted (or the machine running it) the cache will be reset.