Skip to content

Commit

Permalink
fix cache logic
Browse files Browse the repository at this point in the history
  • Loading branch information
roseduan committed Aug 3, 2023
1 parent 0f104aa commit cb70813
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func (seg *segment) readInternal(blockNumber uint32, chunkOffset int64) ([]byte,
// cache the block, so that the next time it can be read from the cache.
// if the block size is smaller than blockSize, it means that the block is not full,
// so we will not cache it.
if seg.cache != nil && size == blockSize {
if seg.cache != nil && size == blockSize && len(cachedBlock) == 0 {
cacheBlock := make([]byte, blockSize)
copy(cacheBlock, bh.block)
seg.cache.Add(seg.getCacheKey(blockNumber), cacheBlock)
Expand Down

0 comments on commit cb70813

Please sign in to comment.