From f2f0482dd332e13f57f0e39b262fa409dacca02e Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 7 Jul 2022 11:50:28 -0700 Subject: [PATCH] mount: random read also try to use the local cache first --- weed/filer/reader_at.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.go index 7d9997761..b938083d8 100644 --- a/weed/filer/reader_at.go +++ b/weed/filer/reader_at.go @@ -164,6 +164,10 @@ func (c *ChunkReadAt) doReadAt(p []byte, offset int64) (n int, err error) { func (c *ChunkReadAt) readChunkSliceAt(buffer []byte, chunkView *ChunkView, nextChunkViews []*ChunkView, offset uint64) (n int, err error) { if c.readerPattern.IsRandomMode() { + n, err := c.readerCache.chunkCache.ReadChunkAt(buffer, chunkView.FileId, offset) + if n > 0 { + return n, err + } return fetchChunkRange(buffer, c.readerCache.lookupFileIdFn, chunkView.FileId, chunkView.CipherKey, chunkView.IsGzipped, int64(offset)) }