diff options
| author | 2026-02-21 13:38:02 +0800 | |
|---|---|---|
| committer | 2026-02-21 14:28:15 +0800 | |
| commit | 94482cb2c97aa215f83940643c5d4c0933727dcb (patch) | |
| tree | bee22fa113542abd1b863ee251fdcf0f9bd409b5 /internal/cache/lru | |
| parent | diff: Add package-level doc comment (diff) | |
| signature | No signature | |
*: Modernize and lint; add CI v0.1.17
Diffstat (limited to 'internal/cache/lru')
| -rw-r--r-- | internal/cache/lru/lru.go | 3 | ||||
| -rw-r--r-- | internal/cache/lru/lru_test.go | 4 |
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 { |
