muesli / cache2go

Concurrency-safe Go caching library with expiration capabilities and access counters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about SetAddedItemCallback

NicholasLiuWei opened this issue · comments

hello
请看如下函数,是不是应该将这这段注释掉
func (table *CacheTable) SetAddedItemCallback(f func(*CacheItem)) {

//if len(table.addedItem) > 0 {
//	table.RemoveAddedItemCallbacks()
//}
table.Lock()
defer table.Unlock()
table.addedItem = append(table.addedItem, f)

}

Please be aware that we only speak English in this repo. From what I can gather, you're suggesting to remove the first three lines? What's the reasoning behind it?

hello
请看如下函数,是不是应该将这这段注释掉
func (table *CacheTable) SetAddedItemCallback(f func(*CacheItem)) {

//if len(table.addedItem) > 0 {
//	table.RemoveAddedItemCallbacks()
//}
table.Lock()
defer table.Unlock()
table.addedItem = append(table.addedItem, f)

}

Because there is already an AddAddedItemCallback,
SetAddedItemCallback is used to replace the current call back function

因為SetAddedItemCallback 是用來取代 當下設定的 回調函式
如果把那三行註解了就跟AddAddedItemCallback函式一樣 是用來增加函式到回調函式列表

So I guess we can close this one.