Skip to content

Commit

Permalink
ThreadSafeCache Get method lock bug (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktear23 authored and disksing committed Mar 30, 2018
1 parent 616b392 commit e221ffb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ func (c *threadSafeCache) Put(key uint64, value interface{}) {
}

// Get retrives an item from cache.
// When Get method called, LRU and TwoQueue cache will rearrange entries
// so we must use write lock.
func (c *threadSafeCache) Get(key uint64) (interface{}, bool) {
c.lock.RLock()
defer c.lock.RUnlock()
c.lock.Lock()
defer c.lock.Unlock()
return c.cache.Get(key)
}

Expand Down

0 comments on commit e221ffb

Please sign in to comment.