Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document / validate positive value for block_for #38

Open
epintos opened this issue Dec 8, 2021 · 2 comments
Open

Document / validate positive value for block_for #38

epintos opened this issue Dec 8, 2021 · 2 comments

Comments

@epintos
Copy link

epintos commented Dec 8, 2021

Hi!

I noticed that if you use 0 as a value for block_for, then Redis raises the exception ERR invalid expire time in setex as soon as a request gets throttled. That is caused by block_duration reaching 0 here and setex failing.

> setex some_key 1 some_value
OK
> setex some_key 0 some_value
(error) ERR invalid expire time in setex

it would be nice to have validation for block_for or some additional documentation.

@d3mash
Copy link

d3mash commented Jan 14, 2022

It would be very nice to document the purpose of block_for parameter

@bdegomme
Copy link
Contributor

bdegomme commented Oct 18, 2022

if anyone reading this is wondering : as far as I can understand from the source code, when a first call to throttle! fails the throttler will block for block_for seconds, meaning all calls to throttle! during that period will immediately fail (without checking the Redis counter). And apparently it must be set to a positive value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants