reset cache if empty

pull/1269/head
Darien Raymond 2018-08-29 17:21:30 +02:00
parent 1add59cd0d
commit 5a0a9aa65e
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 8 additions and 0 deletions

View File

@ -140,6 +140,10 @@ func NewCachedMatcherGroup(g *MatcherGroup) *CachedMatcherGroup {
r.Lock() r.Lock()
defer r.Unlock() defer r.Unlock()
if len(r.cache) == 0 {
return nil
}
expire := time.Now().Add(-1 * time.Second * 120) expire := time.Now().Add(-1 * time.Second * 120)
for p, e := range r.cache { for p, e := range r.cache {
if e.timestamp.Before(expire) { if e.timestamp.Before(expire) {
@ -147,6 +151,10 @@ func NewCachedMatcherGroup(g *MatcherGroup) *CachedMatcherGroup {
} }
} }
if len(r.cache) == 0 {
r.cache = make(map[string]cacheEntry)
}
return nil return nil
}, },
} }