diff --git a/cache.go b/cache.go index 12f7f0b..68458ab 100644 --- a/cache.go +++ b/cache.go @@ -941,12 +941,13 @@ type janitor struct { func (j *janitor) Run(c *cache) { j.stop = make(chan bool) - tick := time.Tick(j.Interval) + ticker := time.NewTicker(j.Interval) for { select { - case <-tick: + case <-ticker.C: c.DeleteExpired() case <-j.stop: + ticker.Stop() return } }