Skip to content

Commit 76e25b3

Browse files
committed
feat: Applies PR review suggestions
1 parent 0086967 commit 76e25b3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

shard.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ func (s *cacheShard) getValidWrapEntry(key string, hashedKey uint64) ([]byte, er
119119

120120
func (s *cacheShard) contains(key string, hashedKey uint64) bool {
121121
s.lock.RLock()
122-
defer s.lock.RUnlock()
123122
wrappedEntry, err := s.getWrappedEntry(hashedKey)
124123
if err != nil {
124+
s.lock.RUnlock()
125125
return false
126126
}
127-
return key == readKeyFromEntry(wrappedEntry)
127+
entryKey := readKeyFromEntry(wrappedEntry)
128+
s.lock.RUnlock()
129+
return key == entryKey
128130
}
129131

130132
func (s *cacheShard) set(key string, hashedKey uint64, entry []byte) error {

0 commit comments

Comments
 (0)