chunk cache adds function ReadChunkAt

This commit is contained in:
chrislu
2022-02-25 21:55:04 -08:00
parent fc7a4957ea
commit 3ad5fa6f6f
5 changed files with 125 additions and 9 deletions

View File

@@ -108,6 +108,26 @@ func (c *OnDiskCacheLayer) getChunkSlice(needleId types.NeedleId, offset, length
}
func (c *OnDiskCacheLayer) readChunkAt(buffer []byte, needleId types.NeedleId, offset uint64) (n int, err error) {
for _, diskCache := range c.diskCaches {
n, err = diskCache.readNeedleSliceAt(buffer, needleId, offset)
if err == storage.ErrorNotFound {
continue
}
if err != nil {
glog.Warningf("failed to read cache file %s id %d: %v", diskCache.fileName, needleId, err)
continue
}
if n > 0 {
return
}
}
return
}
func (c *OnDiskCacheLayer) shutdown() {
for _, diskCache := range c.diskCaches {