Features
Block until ready
You also have the option to try and wait for a request to pass in the given timeout.
It is very similar to the limit
method and takes an identifier and returns the
same response. However if the current limit has already been exceeded, it will
automatically wait until the next window starts and will try again. Setting the
timeout parameter (in seconds) will cause the method to block a finite amount of
time.
Using multiple limits
Sometimes you might want to apply different limits to different users. For example you might want to allow 10 requests per 10 seconds for free users, but 60 requests per 10 seconds for paid users.
Here’s how you could do that:
Custom Rates
When rate limiting, you may want different requests to consume different amounts of tokens. This could be useful when processing batches of requests where you want to rate limit based on items in the batch or when you want to rate limit based on the number of tokens.
To achieve this, you can simply pass rate
parameter when calling the limit method:
Was this page helpful?