Fix leaking the janitor ticker when shutting down
This commit is contained in:
parent
93d85800f2
commit
fe045e4040
5
cache.go
5
cache.go
|
@ -941,12 +941,13 @@ type janitor struct {
|
||||||
|
|
||||||
func (j *janitor) Run(c *cache) {
|
func (j *janitor) Run(c *cache) {
|
||||||
j.stop = make(chan bool)
|
j.stop = make(chan bool)
|
||||||
tick := time.Tick(j.Interval)
|
ticker := time.NewTicker(j.Interval)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-tick:
|
case <-ticker.C:
|
||||||
c.DeleteExpired()
|
c.DeleteExpired()
|
||||||
case <-j.stop:
|
case <-j.stop:
|
||||||
|
ticker.Stop()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue