aboutsummaryrefslogtreecommitdiff
path: root/internal/cache/lru
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cache/lru')
-rw-r--r--internal/cache/lru/lru.go3
-rw-r--r--internal/cache/lru/lru_test.go4
2 files changed, 7 insertions, 0 deletions
diff --git a/internal/cache/lru/lru.go b/internal/cache/lru/lru.go
index fd080bbd..585aaa3f 100644
--- a/internal/cache/lru/lru.go
+++ b/internal/cache/lru/lru.go
@@ -90,6 +90,7 @@ func (cache *Cache[K, V]) Get(key K) (V, bool) {
return zero, false
}
cache.lru.MoveToBack(elem)
+ //nolint:forcetypeassert
return elem.Value.(*entry[K, V]).value, true
}
@@ -100,6 +101,7 @@ func (cache *Cache[K, V]) Peek(key K) (V, bool) {
var zero V
return zero, false
}
+ //nolint:forcetypeassert
return elem.Value.(*entry[K, V]).value, true
}
@@ -161,6 +163,7 @@ func (cache *Cache[K, V]) evictOverBudget() {
}
func (cache *Cache[K, V]) removeElem(elem *list.Element) *entry[K, V] {
+ //nolint:forcetypeassert
ent := elem.Value.(*entry[K, V])
cache.lru.Remove(elem)
delete(cache.items, ent.key)
diff --git a/internal/cache/lru/lru_test.go b/internal/cache/lru/lru_test.go
index 9ce113f0..fbd20f0b 100644
--- a/internal/cache/lru/lru_test.go
+++ b/internal/cache/lru/lru_test.go
@@ -169,6 +169,7 @@ func TestCachePanicsForInvalidConfiguration(t *testing.T) {
t.Parallel()
t.Run("negative max", func(t *testing.T) {
+ t.Parallel()
defer func() {
if recover() == nil {
t.Fatalf("expected panic")
@@ -178,6 +179,7 @@ func TestCachePanicsForInvalidConfiguration(t *testing.T) {
})
t.Run("nil weight function", func(t *testing.T) {
+ t.Parallel()
defer func() {
if recover() == nil {
t.Fatalf("expected panic")
@@ -187,6 +189,7 @@ func TestCachePanicsForInvalidConfiguration(t *testing.T) {
})
t.Run("negative entry weight", func(t *testing.T) {
+ t.Parallel()
cache := lru.New[string, testValue](10, func(_ string, _ testValue) int64 {
return -1
}, nil)
@@ -199,6 +202,7 @@ func TestCachePanicsForInvalidConfiguration(t *testing.T) {
})
t.Run("set negative max", func(t *testing.T) {
+ t.Parallel()
cache := lru.New[string, testValue](10, weightFn, nil)
defer func() {
if recover() == nil {