cache read performance improvements
This commit is contained in:
parent
39c4720e40
commit
f69d3149f3
14 changed files with 140 additions and 71 deletions
|
|
@ -15,6 +15,7 @@ import (
|
|||
type File struct {
|
||||
log logr.Logger
|
||||
f provider.File
|
||||
cache provider.File
|
||||
md *Metadata
|
||||
offset int64
|
||||
offline bool
|
||||
|
|
@ -83,7 +84,7 @@ func (f *File) Preload(ctx context.Context, unlock func()) {
|
|||
func (f *File) Read(p []byte) (n int, err error) {
|
||||
log := f.log
|
||||
if f.hasChunk(len(p)) {
|
||||
n, err = f.md.ReadAt(p, f.offset)
|
||||
n, err = f.cache.ReadAt(p, f.offset)
|
||||
if err == io.EOF {
|
||||
return
|
||||
}
|
||||
|
|
@ -172,8 +173,8 @@ func (f *File) Stat() (os.FileInfo, error) {
|
|||
}
|
||||
|
||||
func (f *File) Close() error {
|
||||
if f.offline {
|
||||
return nil
|
||||
if !f.offline && f.cache != nil {
|
||||
f.cache.Close()
|
||||
}
|
||||
return f.f.Close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue