Skip to content

Commit

Permalink
Change cache interface to use internal Len method
Browse files Browse the repository at this point in the history
  • Loading branch information
Eero Norri committed Aug 7, 2023
1 parent f08595a commit 3621c33
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ func (c *Cache[K, V]) Delete(key K) {

// Len returns the number of items in the cache.
func (c *Cache[K, V]) Len() int {
return len(c.Keys())
c.mu.Lock()
defer c.mu.Unlock()
return c.cache.Len()
}

// Contains reports whether key is within cache.
Expand Down

0 comments on commit 3621c33

Please sign in to comment.