Skip to content

Commit

Permalink
Remove expensive cache evictions
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Nov 16, 2022
1 parent 548b6f2 commit af63966
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions internal/promapi/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,6 @@ func (c *queryCache) set(key uint64, val queryResult, ttl time.Duration, cost in
}

func (c *queryCache) makeRoom(needed int) {
now := time.Now()
for key, ce := range c.entries {
if !ce.expiresAt.IsZero() && ce.expiresAt.Before(now) {
c.cost -= ce.cost
needed -= ce.cost
c.useList.Remove(ce.lst)
delete(c.entries, key)
c.evictions++
}
}
if needed <= 0 {
return
}

for c.useList.Len() > 0 && needed > 0 {
if lst := c.useList.Back(); lst != nil {
key := lst.Value.(uint64)
Expand Down

0 comments on commit af63966

Please sign in to comment.