diff --git a/algorithms.go b/algorithms.go index 8f4bea6a..c9231610 100644 --- a/algorithms.go +++ b/algorithms.go @@ -146,18 +146,18 @@ func tokenBucket(ctx context.Context, s Store, c Cache, r *RateLimitReq, reqStat rl.ResetTime = expire } - // Client is only interested in retrieving the current status or - // updating the rate limit config. - if r.Hits == 0 { - return rl, nil - } - if s != nil && reqState.IsOwner { defer func() { s.OnChange(ctx, r, item) }() } + // Client is only interested in retrieving the current status or + // updating the rate limit config. + if r.Hits == 0 { + return rl, nil + } + // If we are already at the limit. if rl.Remaining == 0 && r.Hits > 0 { trace.SpanFromContext(ctx).AddEvent("Already over the limit")