go-redis / redis_rate

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

redis_rate.PerDay() ?? #81

Open canalun opened 1 year ago

canalun commented 1 year ago

Hi, thank you for developing this really useful rate limiter!! I'm now about to use this library😃

And I thought what about supporting redis_rate.PerDay(). As you know, currently, we have only choices of PerSec(), PerMin() and PerHour(). However, some ppl (not only me, maybe) might wanna set limits per day.

If it doesn't sound like a bad idea, if I may, I would like to work on it😊 Would be really happy if you gave me a reply...!

tony95271 commented 1 year ago

Hi, thank you for developing this really useful rate limiter!! I'm now about to use this library😃

And I thought what about supporting redis_rate.PerDay(). As you know, currently, we have only choices of PerSec(), PerMin() and PerHour(). However, some ppl (not only me, maybe) might wanna set limits per day.

If it doesn't sound like a bad idea, if I may, I would like to work on it😊 Would be really happy if you gave me a reply...!

you could walk around this issue https://github.com/tonytony2020/redis_rate/wiki#usage

tanto-satu commented 1 year ago

is there any follow up regarding this issue? or can somebody provide some example to do it for perDay?

tikhomirovv commented 4 months ago

@tanto-satu, I suppose it should be like this:

// limit := redis_rate.PerMinute(rate)
limit := redis_rate.Limit{
        Rate:   rate,
        Burst:  rate,
        Period: time.Hour * 24,
}