Skip to content

Commit 3621c33

Browse files
author
Eero Norri
committed
Change cache interface to use internal Len method
1 parent f08595a commit 3621c33

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cache.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ func (c *Cache[K, V]) Delete(key K) {
257257

258258
// Len returns the number of items in the cache.
259259
func (c *Cache[K, V]) Len() int {
260-
return len(c.Keys())
260+
c.mu.Lock()
261+
defer c.mu.Unlock()
262+
return c.cache.Len()
261263
}
262264

263265
// Contains reports whether key is within cache.

0 commit comments

Comments
 (0)