Skip to content

Commit

Permalink
use read lock (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiaoliang authored Sep 17, 2020
1 parent 8a9ec41 commit 769555c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ func (m *Manager) addDimensionInfo(labels map[string]string) error {

// IsKeyExist check if key exist in cache
func (m *Manager) IsKeyExist(key string) bool {
m.configMapMux.Lock()
defer m.configMapMux.Unlock()
m.configMapMux.RLock()
defer m.configMapMux.RUnlock()

if _, ok := m.ConfigurationMap[key]; ok {
return true
Expand All @@ -277,9 +277,9 @@ func (m *Manager) IsKeyExist(key string) bool {

// GetConfig returns the value for a particular key from cache
func (m *Manager) GetConfig(key string) interface{} {
m.configMapMux.Lock()
m.configMapMux.RLock()
sourceName, ok := m.ConfigurationMap[key]
m.configMapMux.Unlock()
m.configMapMux.RUnlock()
if !ok {
return nil
}
Expand Down

0 comments on commit 769555c

Please sign in to comment.