πŸ”— go-redis-ratelimiter - Simple thread-safe go ratelimiter library with redis backend

Usage:

// increment rate limit usage for given key that is allowed 10 requests per second
limitCtx, err := ratelimiter.Incr(utils.Redis, "mykey", 10, time.Second)

if err != nil {
    // do something
}

// limitCtx contains all necessary data for ratelimiter state
if limitCtx.Reached() {
    // code to handle over the limit logic
}

🌎 https://github.com/oeegor/go-redis-ratelimiter