Update lookup_cache.go

MatchingCache struct hold a RWLock, so Get operation of Cache should use RLock properly, nor WLock
This commit is contained in:
zhangke 2016-05-16 15:26:30 +08:00
parent 1cba05574b
commit 49f4f242a8

View File

@ -72,8 +72,8 @@ func (c *MatchingCache) Add(labelObj objectWithMeta, selectorObj objectWithMeta)
// we need check in the external request to ensure the cache data is not dirty.
func (c *MatchingCache) GetMatchingObject(labelObj objectWithMeta) (controller interface{}, exists bool) {
key := keyFunc(labelObj)
c.mutex.Lock()
defer c.mutex.Unlock()
c.mutex.RLock()
defer c.mutex.RUnlock()
return c.cache.Get(key)
}