Commit 49362c2e authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Store the timer for RecurringPurge so it can be stopped.

parent 8c4e550c
...@@ -26,6 +26,8 @@ type TimedCache struct { ...@@ -26,6 +26,8 @@ type TimedCache struct {
cacheMapMutex sync.RWMutex cacheMapMutex sync.RWMutex
cacheMap map[string]*cacheEntry cacheMap map[string]*cacheEntry
PurgeTimer *time.Timer
} }
const layerCacheTimeoutNs = 1e9 const layerCacheTimeoutNs = 1e9
...@@ -85,6 +87,6 @@ func (me *TimedCache) Purge() { ...@@ -85,6 +87,6 @@ func (me *TimedCache) Purge() {
func (me *TimedCache) RecurringPurge() { func (me *TimedCache) RecurringPurge() {
me.Purge() me.Purge()
time.AfterFunc(5*me.ttlNs, me.PurgeTimer = time.AfterFunc(5*me.ttlNs,
func() { me.RecurringPurge() }) func() { me.RecurringPurge() })
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment