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
func (c*cache) Set(kstring, xinterface{}, d time.Duration) {
func (c *cache) Set(k string, x interface{}, d time.Duration) {
// "Inlining" of set
var e int64
if d == DefaultExpiration {
d = c.defaultExpiration
}
if d > 0 {
e = time.Now().Add(d).UnixNano()
}
c.mu.Lock()
c.items[k] = Item{
Object: x,
Expiration: e,
}
// TODO: Calls to mu.Unlock are currently not deferred because defer
// adds ~200 ns (as of go1.)
c.mu.Unlock()
}
don't check if has the expired value and perform the onEvicted function, that may lead to unexpected result.
The text was updated successfully, but these errors were encountered:
The method
Get
will return false when the key has been expired, the user will reset the key usually. But the methodSet
go-cache/cache.go
Line 51 in 46f4078
don't check if has the expired value and perform the
onEvicted
function, that may lead to unexpected result.The text was updated successfully, but these errors were encountered: