Skip to content

Commit

Permalink
fx: mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
martinsaporiti committed Oct 2, 2024
1 parent 94a4e82 commit f07b643
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/loader/w3c_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ type W3CDocumentLoader struct {
}

type w3CDocumentLoaderLocalCache struct {
mutex sync.Mutex
mutex sync.RWMutex
data map[string]*ld.RemoteDocument
}

func newLocalCache() *w3CDocumentLoaderLocalCache {
return &w3CDocumentLoaderLocalCache{
mutex: sync.Mutex{},
mutex: sync.RWMutex{},
data: make(map[string]*ld.RemoteDocument),
}
}
Expand All @@ -39,8 +39,8 @@ func (c *w3CDocumentLoaderLocalCache) Get(key string) (doc *ld.RemoteDocument, e

func (c *w3CDocumentLoaderLocalCache) Set(key string, doc *ld.RemoteDocument, expireTime time.Time) error {
c.mutex.Lock()
defer c.mutex.Unlock()
c.data[key] = doc
c.mutex.Unlock()
return nil
}

Expand Down

0 comments on commit f07b643

Please sign in to comment.