Add DeleteFunc
This shares DeletePrefixs's implementation.
This commit is contained in:
9
cache.go
9
cache.go
@@ -63,6 +63,15 @@ func (c *Cache) DeletePrefix(prefix string) int {
|
||||
return count
|
||||
}
|
||||
|
||||
// Deletes all items that the matches func evaluates to true.
|
||||
func (c *Cache) DeleteFunc(matches func(key string, item interface{}) bool) int {
|
||||
count := 0
|
||||
for _, b := range c.buckets {
|
||||
count += b.deleteFunc(matches, c.deletables)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Get an item from the cache. Returns nil if the item wasn't found.
|
||||
// This can return an expired item. Use item.Expired() to see if the item
|
||||
// is expired and item.TTL() to see how long until the item expires (which
|
||||
|
Reference in New Issue
Block a user