Просмотр исходного кода

Rename removeOldest to include max capacity condition

Matt Bolt 4 лет назад
Родитель
Сommit
edd9822b89
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      pkg/util/cache/cachegroup.go

+ 2 - 2
pkg/util/cache/cachegroup.go

@@ -59,7 +59,7 @@ func (cg *CacheGroup[T]) Do(key string, factory func() (T, error)) (T, error) {
 
 		// assign cache once a result for the group key is returned
 		cg.lock.Lock()
-		cg.removeOldest()
+		cg.removeOldestBeyondCapacity()
 		cg.cache[key] = &cacheEntry[T]{
 			item: i,
 			ts:   time.Now(),
@@ -115,7 +115,7 @@ func (cg *CacheGroup[T]) DisableExpiration() {
 
 // locates the oldest entry and removes it from the map. caller should lock
 // prior to calling
-func (cg *CacheGroup[T]) removeOldest() {
+func (cg *CacheGroup[T]) removeOldestBeyondCapacity() {
 	// only remove the oldest entries if we're at max capacity
 	if len(cg.cache) < cg.max {
 		return