cache2go
cache2go copied to clipboard
AfterFunc with go
if smallestDuration > 0 {
table.cleanupTimer = time.AfterFunc(smallestDuration, func() {
go table.expirationCheck()
})
}
AfterFunc creates a new goroute.Is it necessary to use 'go' in 'AfterFunc'
I think it's preferred because otherwise cleaning up the table (which can be a costly routine) would block the caller.
I think "go" should be here:
if item.lifeSpan > 0 && (expDur == 0 || item.lifeSpan < expDur) {
go table.expirationCheck()
}
I think "go" should be here:
if item.lifeSpan > 0 && (expDur == 0 || item.lifeSpan < expDur) { go table.expirationCheck() }
it will run more times, not just run once for smallestDuration
I think "go" should be here:
if item.lifeSpan > 0 && (expDur == 0 || item.lifeSpan < expDur) { go table.expirationCheck() }
it will run more times, not just run once for smallestDuration
??