You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Value returns an item from the cache and marks it to be kept alive. You can// pass additional arguments to your DataLoader callback function.func (table*CacheTable) Value(keyinterface{}, args...interface{}) (*CacheItem, error) {
table.RLock()
r, ok:=table.items[key]
loadData:=table.loadDatatable.RUnlock()
ifok {
// Update access counter and timestamp.r.KeepAlive()
returnr, nil
}
// Item doesn't exist in cache. Try and fetch it with a data-loader.ifloadData!=nil {
item:=loadData(key, args...)
ifitem!=nil {
table.Add(key, item.lifeSpan, item.data)
returnitem, nil
}
returnnil, ErrKeyNotFoundOrLoadable
}
returnnil, ErrKeyNotFound
}
The text was updated successfully, but these errors were encountered:
winxxp
changed the title
dataload not thread safe
if register dataload, Value() not thread safe
Jul 22, 2019
winxxp
changed the title
if register dataload, Value() not thread safe
if registered dataload, Value() not thread safe
Jul 22, 2019
if value is file handle, key is filename, so kV is filename -> file handle.
eg. thread 1,2,... call Value(filename) , and filename is not in cache, so all thread will call loadData to open same filename.
The text was updated successfully, but these errors were encountered: