add ForEachFunc
This commit is contained in:
10
cache.go
10
cache.go
@@ -76,6 +76,14 @@ func (c *Cache) DeleteFunc(matches func(key string, item *Item) bool) int {
|
||||
return count
|
||||
}
|
||||
|
||||
func (c *Cache) ForEachFunc(matches func(key string, item *Item) bool) {
|
||||
for _, b := range c.buckets {
|
||||
if !b.forEachFunc(matches) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -210,7 +218,7 @@ func (c *Cache) promote(item *Item) {
|
||||
case c.promotables <- item:
|
||||
default:
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func (c *Cache) worker() {
|
||||
|
||||
Reference in New Issue
Block a user