Skip to content

Commit 51e3953

Browse files
Ensure size reads are threadsafe.
1 parent 9937fb4 commit 51e3953

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cache/cache.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ func (c *cache) Remove(keys ...string) {
143143
}
144144
}
145145

146+
// Size returns the current size of the cache. This method is threadsafe.
146147
func (c *cache) Size() uint64 {
148+
c.Lock()
149+
defer c.Unlock()
150+
147151
return c.size
148152
}
149153

0 commit comments

Comments
 (0)