From b7719d59c2e0072e4b6997d34db99574733385d5 Mon Sep 17 00:00:00 2001 From: Lewis Christie Date: Mon, 7 Oct 2024 11:25:57 -0600 Subject: [PATCH] Fix concurrent map write due to read lock and delete (#3457) --- internal/cache/cache.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/cache/cache.go b/internal/cache/cache.go index c60713707..7c422ee87 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -84,8 +84,8 @@ func NewExpiringCache[V any](name string) *ExpiringCache[V] { // Get - fetch value from cache by key func (c *ExpiringCache[V]) Get(ctx context.Context, key string) (V, bool) { - c.Mutex.RLock() - defer c.Mutex.RUnlock() + c.Mutex.Lock() + defer c.Mutex.Unlock() item, found := c.Cache[key] telemetry.Count(ctx, c.Name+"_cache_get", 1)