cache read performance improvements

This commit is contained in:
ston1th 2022-05-19 01:29:23 +02:00
commit f69d3149f3
14 changed files with 140 additions and 71 deletions

View file

@ -389,16 +389,16 @@ func (md *Metadata) AddChunk(off int64, n int) {
md.Chunks.Add(off, n)
}
func (md *Metadata) ReadAt(p []byte, pos int64) (int, error) {
if md.f == nil {
err := md.openCacheFile()
if err != nil {
return 0, err
}
}
atomic.StoreInt64(&md.Atime, now())
return md.f.ReadAt(p, pos)
}
//func (md *Metadata) ReadAt(p []byte, pos int64) (int, error) {
// if md.f == nil {
// err := md.openCacheFile()
// if err != nil {
// return 0, err
// }
// }
// atomic.StoreInt64(&md.Atime, now())
// return md.f.ReadAt(p, pos)
//}
func (md *Metadata) WriteAt(data []byte, pos int64) (int, error) {
if md.f == nil {