prorate icon indicating copy to clipboard operation
prorate copied to clipboard

Document / validate positive value for block_for

Open epintos opened this issue 4 years ago • 2 comments

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.

epintos avatar Dec 08 '21 08:12 epintos

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

d3mash avatar Jan 14 '22 10:01 d3mash

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.

bdegomme avatar Oct 18 '22 06:10 bdegomme