Skip to content

Commit

Permalink
fix: use mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
mathnogueira committed Sep 14, 2023
1 parent 16abd8e commit 45109cb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/traces/caching.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ var cache spanCache = nil
var cacheMutex sync.Mutex

func getCache() spanCache {
cacheMutex.Lock()
defer cacheMutex.Unlock()

if cache == nil {
cache = spanCache{}
}
Expand All @@ -16,6 +19,9 @@ func getCache() spanCache {
}

func resetCache() {
cacheMutex.Lock()
defer cacheMutex.Unlock()

cache = nil
}

Expand Down

0 comments on commit 45109cb

Please sign in to comment.