Skip to content
This repository was archived by the owner on Apr 19, 2024. It is now read-only.

Commit b347f24

Browse files
authored
Merge pull request #20 from mailgun/dietz/REP-937
Requests over remaining shouldn't change remaining
2 parents 4e0a902 + 08f8411 commit b347f24

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

algorithms.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func tokenBucket(c cache.Cache, r *RateLimitReq) (*RateLimitResp, error) {
7777
// Client could be requesting that we always return OVER_LIMIT
7878
if r.Hits > r.Limit {
7979
status.Status = Status_OVER_LIMIT
80-
status.Remaining = 0
80+
status.Remaining = r.Limit
8181
}
8282

8383
c.Add(r.HashKey(), status, expire)

cache/lru.go

+4
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ func (c *LRUCache) Size() int {
146146
return c.ll.Len()
147147
}
148148

149+
func (c *LRUCache) Stats(_ bool) Stats {
150+
return c.stats
151+
}
152+
149153
// Update the expiration time for the key
150154
func (c *LRUCache) UpdateExpiration(key Key, expireAt int64) bool {
151155
if ele, hit := c.cache[key]; hit {

0 commit comments

Comments
 (0)