mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactoring: use interface
This commit is contained in:
parent
be4d42b8e2
commit
09e126bae5
|
@ -19,7 +19,7 @@ type ChunkReadAt struct {
|
||||||
readerLock sync.Mutex
|
readerLock sync.Mutex
|
||||||
fileSize int64
|
fileSize int64
|
||||||
|
|
||||||
chunkCache *chunk_cache.TieredChunkCache
|
chunkCache chunk_cache.ChunkCache
|
||||||
}
|
}
|
||||||
|
|
||||||
// var _ = io.ReaderAt(&ChunkReadAt{})
|
// var _ = io.ReaderAt(&ChunkReadAt{})
|
||||||
|
@ -53,7 +53,7 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewChunkReaderAtFromClient(filerClient filer_pb.FilerClient, chunkViews []*ChunkView, chunkCache *chunk_cache.TieredChunkCache, fileSize int64) *ChunkReadAt {
|
func NewChunkReaderAtFromClient(filerClient filer_pb.FilerClient, chunkViews []*ChunkView, chunkCache chunk_cache.ChunkCache, fileSize int64) *ChunkReadAt {
|
||||||
|
|
||||||
return &ChunkReadAt{
|
return &ChunkReadAt{
|
||||||
chunkViews: chunkViews,
|
chunkViews: chunkViews,
|
||||||
|
|
|
@ -13,6 +13,11 @@ const (
|
||||||
onDiskCacheSizeLimit1 = 4 * memCacheSizeLimit
|
onDiskCacheSizeLimit1 = 4 * memCacheSizeLimit
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ChunkCache interface {
|
||||||
|
GetChunk(fileId string, minSize uint64) (data []byte)
|
||||||
|
SetChunk(fileId string, data []byte)
|
||||||
|
}
|
||||||
|
|
||||||
// a global cache for recently accessed file chunks
|
// a global cache for recently accessed file chunks
|
||||||
type TieredChunkCache struct {
|
type TieredChunkCache struct {
|
||||||
memCache *ChunkCacheInMemory
|
memCache *ChunkCacheInMemory
|
||||||
|
|
Loading…
Reference in a new issue