Unverified Commit 03399a60 authored by jinjingroad's avatar jinjingroad Committed by GitHub

refactor: use the built-in max/min to simplify the code (#4781)

Signed-off-by: 's avatarjinjingroad <jinjingroad@sina.com>
parent e6e46049
...@@ -251,10 +251,8 @@ func (c *Cache) cleanup() { ...@@ -251,10 +251,8 @@ func (c *Cache) cleanup() {
// cleanupOldest removes the oldest items if we're over the max items. // cleanupOldest removes the oldest items if we're over the max items.
func (c *Cache) cleanupOldest() { func (c *Cache) cleanupOldest() {
threshold := c.config.MaxItems / 5 // Remove 20% of max items at once // Remove 20% of max items at once
if threshold < 1 { threshold := max(c.config.MaxItems/5, 1)
threshold = 1
}
currentCount := atomic.LoadInt64(&c.itemCount) currentCount := atomic.LoadInt64(&c.itemCount)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment