Skip to content

Commit

Permalink
Use sync.RWMutex instead of sync.Mute.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxki committed Sep 30, 2023
1 parent 89454a5 commit 95d0623
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/cache/res_cache_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type ResponseCacheStore struct {
cacheMap map[string]ResponseCache
now date.Now
UpdatedAt time.Time
mu sync.Mutex
mu sync.RWMutex
}

// NewResponseCacheStore creates and retruns new instance of ResponseCacheStore.
Expand Down Expand Up @@ -117,9 +117,9 @@ func (r *ResponseCacheStore) Get(serialNumber *big.Int) (*ResponseCache, bool) {

// Copy the cache map address for data protection
// from replacing address by the updating cache job
r.mu.Lock()
r.mu.RLock()
cm := r.cacheMap
r.mu.Unlock()
r.mu.RUnlock()
cache, ok = cm[key]
if !ok {
return nil, false
Expand Down

0 comments on commit 95d0623

Please sign in to comment.