update spf13/cobra dependency to 1.0.0

This commit is contained in:
louisgong
2020-05-13 15:27:34 +08:00
parent e26af96b8e
commit 205ded20da
91 changed files with 8428 additions and 315 deletions

View File

@@ -25,7 +25,7 @@ type Cache struct {
// an item is evicted. Zero means no limit.
MaxEntries int
// OnEvicted optionally specificies a callback function to be
// OnEvicted optionally specifies a callback function to be
// executed when an entry is purged from the cache.
OnEvicted func(key Key, value interface{})
@@ -119,3 +119,15 @@ func (c *Cache) Len() int {
}
return c.ll.Len()
}
// Clear purges all stored items from the cache.
func (c *Cache) Clear() {
if c.OnEvicted != nil {
for _, e := range c.cache {
kv := e.Value.(*entry)
c.OnEvicted(kv.key, kv.value)
}
}
c.ll = nil
c.cache = nil
}