X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=common%2Fconcurrent_lru.go;h=68e6e5e199c65179655abaa561cedd8384d22e3e;hb=b12c7b5f50749a73b4599c1c15d8e242deb64e8e;hp=8e9a34443804694f80071ed2e43986c81f4c7d78;hpb=54373c1a3efe0e373ec1605840a4363e4b246c46;p=bytom%2Fvapor.git 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) }