diff --git a/app/rest/cache/memory.go b/app/rest/cache/memory.go index 56511ae3..df50e9aa 100644 --- a/app/rest/cache/memory.go +++ b/app/rest/cache/memory.go @@ -93,18 +93,12 @@ func (m *memoryCache) Flush(scopes ...string) { return false } - // all matchedKeys should be collected first - // we can't delete it from locked section, it will lock on eviction callback - matchedKeys := []string{} for _, k := range m.bytesCache.Keys() { key := k.(string) if inScope(key) { - matchedKeys = append(matchedKeys, key) + m.bytesCache.Remove(key) // Keys() returns copy of cache's key, safe to remove directly } } - for _, mkey := range matchedKeys { - m.bytesCache.Remove(mkey) - } if m.postFlushFn != nil { go m.postFlushFn()