From 0bd475676b90322bfca03ca3c359c2a7df8161d6 Mon Sep 17 00:00:00 2001 From: Takashi Kusumi Date: Thu, 8 Sep 2016 00:22:07 +0900 Subject: [PATCH] LRUExpireCache#Get requires write lock --- pkg/util/cache/lruexpirecache.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/util/cache/lruexpirecache.go b/pkg/util/cache/lruexpirecache.go index 7e1bb65a87b..99e62cdc672 100644 --- a/pkg/util/cache/lruexpirecache.go +++ b/pkg/util/cache/lruexpirecache.go @@ -25,7 +25,7 @@ import ( type LRUExpireCache struct { cache *lru.Cache - lock sync.RWMutex + lock sync.Mutex } func NewLRUExpireCache(maxSize int) *LRUExpireCache { @@ -46,8 +46,8 @@ func (c *LRUExpireCache) Add(key lru.Key, value interface{}, ttl time.Duration) } func (c *LRUExpireCache) Get(key lru.Key) (interface{}, bool) { - c.lock.RLock() - defer c.lock.RUnlock() + c.lock.Lock() + defer c.lock.Unlock() e, ok := c.cache.Get(key) if !ok { return nil, false