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

Commit

Permalink
Merge pull request #20 from mailgun/dietz/REP-937
Browse files Browse the repository at this point in the history
Requests over remaining shouldn't change remaining
  • Loading branch information
MattDietz authored Oct 29, 2019
2 parents 4e0a902 + 08f8411 commit b347f24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion algorithms.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func tokenBucket(c cache.Cache, r *RateLimitReq) (*RateLimitResp, error) {
// Client could be requesting that we always return OVER_LIMIT
if r.Hits > r.Limit {
status.Status = Status_OVER_LIMIT
status.Remaining = 0
status.Remaining = r.Limit
}

c.Add(r.HashKey(), status, expire)
Expand Down
4 changes: 4 additions & 0 deletions cache/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ func (c *LRUCache) Size() int {
return c.ll.Len()
}

func (c *LRUCache) Stats(_ bool) Stats {
return c.stats
}

// Update the expiration time for the key
func (c *LRUCache) UpdateExpiration(key Key, expireAt int64) bool {
if ele, hit := c.cache[key]; hit {
Expand Down

0 comments on commit b347f24

Please sign in to comment.