Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions cachetable.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (table *CacheTable) SetAddedItemCallback(f func(*CacheItem)) {
table.addedItem = append(table.addedItem, f)
}

//AddAddedItemCallback appends a new callback to the addedItem queue
// AddAddedItemCallback appends a new callback to the addedItem queue
func (table *CacheTable) AddAddedItemCallback(f func(*CacheItem)) {
table.Lock()
defer table.Unlock()
Expand Down Expand Up @@ -181,10 +181,8 @@ func (table *CacheTable) addInternal(item *CacheItem) {
table.Unlock()

// Trigger callback after adding an item to cache.
if addedItem != nil {
for _, callback := range addedItem {
callback(item)
}
for _, callback := range addedItem {
callback(item)
}

// If we haven't set up any expiration check timer or found a more imminent item.
Expand Down Expand Up @@ -219,10 +217,8 @@ func (table *CacheTable) deleteInternal(key interface{}) (*CacheItem, error) {
table.Unlock()

// Trigger callbacks before deleting an item from cache.
if aboutToDeleteItem != nil {
for _, callback := range aboutToDeleteItem {
callback(r)
}
for _, callback := range aboutToDeleteItem {
callback(r)
}

r.RLock()
Expand Down