viafintech / gcra-ruby

Generic cell rate algorithm (leaky bucket) implementation for rate limiting
MIT License
51 stars 10 forks source link

Support handling very high limits/0 as ttl #1

Closed tobischo closed 6 years ago

tobischo commented 7 years ago

With very high limits the calculated TTL may be set to 0. Redis does not support 0 as expiration time for its keys. Therefore to properly remove those keys from redis again, this sets the value to 1 (in milliseconds) if the given ttl_nano is less than 1 millisecond.

tobischo commented 6 years ago

@Faffnir This seems to have gotten lost last year. Would you mind reviewing it?