Skip to content

Commit

Permalink
Fix concurrent map write due to read lock and delete (#3457)
Browse files Browse the repository at this point in the history
  • Loading branch information
Resonance1584 authored Oct 7, 2024
1 parent e7ddb35 commit b7719d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b7719d5

Please sign in to comment.