From a20e46a80f0355a7d5dd64454c8954d69f6854e6 Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Tue, 27 Feb 2024 23:03:49 -0500 Subject: [PATCH] util/cache: fix missing interface methods (#11275) Updates #cleanup Change-Id: Ib3a33a7609530ef8c9f3f58fc607a61e8655c4b5 Signed-off-by: Andrew Dunham --- util/cache/none.go | 7 ++++++- util/cache/single.go | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/util/cache/none.go b/util/cache/none.go index e3e53e0b4..c4073e0d9 100644 --- a/util/cache/none.go +++ b/util/cache/none.go @@ -8,6 +8,8 @@ package cache // It is safe for concurrent use if the underlying FillFunc is. type None[K comparable, V any] struct{} +var _ Cache[int, int] = None[int, int]{} + // Get always calls the provided FillFunc and returns what it does. func (c None[K, V]) Get(_ K, f FillFunc[V]) (V, error) { v, _, e := f() @@ -15,4 +17,7 @@ func (c None[K, V]) Get(_ K, f FillFunc[V]) (V, error) { } // Forget implements Cache. -func (c None[K, V]) Forget() {} +func (None[K, V]) Forget(K) {} + +// Empty implements Cache. +func (None[K, V]) Empty() {} diff --git a/util/cache/single.go b/util/cache/single.go index 5b378cc15..6b9ac2c11 100644 --- a/util/cache/single.go +++ b/util/cache/single.go @@ -25,6 +25,8 @@ type Single[K comparable, V any] struct { ServeExpired bool } +var _ Cache[int, int] = (*Single[int, int])(nil) + // Get will return the cached value, if any, or fill the cache by calling f and // return the corresponding value. If f returns an error and c.ServeExpired is // true, then a previous expired value can be returned with no error.