diff --git a/bigcache.go b/bigcache.go index b3aa37b..8328e93 100644 --- a/bigcache.go +++ b/bigcache.go @@ -188,6 +188,14 @@ func (c *BigCache) ResetStats() error { return nil } +// ResetKeyMetadata resets per-key metadata +func (c *BigCache) ResetKeyMetadata() error { + for _, shard := range c.shards { + shard.resetKeyMetadata(c.config) + } + return nil +} + // Len computes the number of entries in the cache. func (c *BigCache) Len() int { var len int diff --git a/shard.go b/shard.go index 4f03b53..d9c2543 100644 --- a/shard.go +++ b/shard.go @@ -359,6 +359,12 @@ func (s *cacheShard) resetStats() { s.lock.Unlock() } +func (s *cacheShard) resetKeyMetadata(config Config) { + s.lock.Lock() + s.hashmapStats = make(map[uint64]uint32, config.initialShardSize()) + s.lock.Unlock() +} + func (s *cacheShard) len() int { s.lock.RLock() res := len(s.hashmap)