Update k8s.io/utils to a36077c30491

Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
This commit is contained in:
Anish Ramasekar
2023-02-09 20:09:41 +00:00
parent d35da348c6
commit 09e02052fd
59 changed files with 96 additions and 88 deletions

10
vendor/k8s.io/utils/lru/lru.go generated vendored
View File

@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,6 +22,7 @@ import (
)
type Key = groupcache.Key
type EvictionFunc = func(key Key, value interface{})
// Cache is a thread-safe fixed size LRU cache.
type Cache struct {
@@ -36,6 +37,13 @@ func New(size int) *Cache {
}
}
// NewWithEvictionFunc creates an LRU of the given size with the given eviction func.
func NewWithEvictionFunc(size int, f EvictionFunc) *Cache {
c := New(size)
c.cache.OnEvicted = f
return c
}
// Add adds a value to the cache.
func (c *Cache) Add(key Key, value interface{}) {
c.lock.Lock()