实现open file cache

This commit is contained in:
刘祥超
2022-01-12 21:09:00 +08:00
parent 91fab59a18
commit d02f9f9a0e
12 changed files with 553 additions and 144 deletions

View File

@@ -0,0 +1,31 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package caches
import (
"io"
"os"
)
type OpenFile struct {
fp *os.File
meta []byte
version int64
}
func NewOpenFile(fp *os.File, meta []byte) *OpenFile {
return &OpenFile{
fp: fp,
meta: meta,
}
}
func (this *OpenFile) SeekStart() error {
_, err := this.fp.Seek(0, io.SeekStart)
return err
}
func (this *OpenFile) Close() error {
this.meta = nil
return this.fp.Close()
}