From 4df1f60fba8ae222e3deb3cc339fa9957c29fd98 Mon Sep 17 00:00:00 2001 From: Paladz Date: Thu, 27 Jun 2019 20:32:56 +0800 Subject: [PATCH] fix lru issue (#230) --- common/concurrent_lru.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/concurrent_lru.go b/common/concurrent_lru.go index 8e9a3444..68e6e5e1 100644 --- a/common/concurrent_lru.go +++ b/common/concurrent_lru.go @@ -8,7 +8,7 @@ import ( // Cache is an LRU cache. It is safe for concurrent access. type Cache struct { - cache *lru.Cache + cache *lru.Cache sync.RWMutex } @@ -28,8 +28,8 @@ func (c *Cache) Add(key, value interface{}) { // Get looks up a key's value from the cache. func (c *Cache) Get(key interface{}) (value interface{}, ok bool) { - c.RLock() - defer c.RUnlock() + c.Lock() + defer c.Unlock() return c.cache.Get(key) } -- 2.11.0