Skip to content

Commit

Permalink
[REMOVE] refill token if not provide
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas-ggd committed Jun 28, 2024
1 parent 6a4c0bf commit f0c24f4
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ func (rl *RateLimiter) IsRequestAllowed(key string, tokens int64) bool {
return false
}

// if no previous data, initialize token count and last refill time
if errors.Is(err, redis.Nil) {
tokenCount = tokens
lastRefillTime = time.Now()
rl.client.Set(context.Background(), sEnc, tokenCount, 0)
rl.client.Set(context.Background(), sEnc+"_lastRefillTime", lastRefillTime.Format(time.RFC3339), 0)
}

// refill tokens
tokenCount, lastRefillTime = rl.refillBucket(lastRefillTime, tokenCount)

Expand Down

0 comments on commit f0c24f4

Please sign in to comment.