go-redis / redis_rate

Rate limiting for go-redis
https://redis.uptrace.dev/guide/go-redis-rate-limiting.html
BSD 2-Clause "Simplified" License
851 stars 101 forks source link

why burst_offset is neccessary #91

Closed wondar-chan closed 12 months ago

wondar-chan commented 12 months ago

in allowN's script, I found burst_offset, which is curious, is not necessary. In fact, increment is okay to calculate remaining token.

wondar-chan commented 12 months ago

I think about it for day long, now i get it! This limiter is based on sliding window. So, the burst_offset, increment are the parts of windows.