Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFileCacheActor ¶
func NewFileCacheActor( fileSize int, chunkSize int, fetchSize int, fetcher Fetcher, chunkCache ChunkCache, ) (virtual.ActorStream, error)
NewFileCacheActor creates a new FileCacheActor.
Types ¶
type ChunkCache ¶
type ChunkCache interface { Get(b []byte, chunkIdx int) ([]byte, bool, error) Put(chunkIdx int, b []byte) error }
ChunkCache is the interface that must be implemented by the cache that will cache "chunks" of the data fetched from the source via the Fetcher interface.
type Fetcher ¶
type Fetcher interface {
FetchRange(ctx context.Context, offset, length int) (io.ReadCloser, error)
}
Fetcher is the interface that must be implemented to fetch ranges of data from the source.
type FileCacheActor ¶
FileCacheActor is the implementation of the file cache actor and will be spawned 1:1 with a corresponding file, I.E we will have one actor per file that needs to have portions of its data cached. The actor deduplicates fetches of ranges of data from the source, and also caches the fetched data as chunks in memory for subsequent reads.
func (*FileCacheActor) InvokeStream ¶
func (f *FileCacheActor) InvokeStream( ctx context.Context, operation string, payload []byte, ) (io.ReadCloser, error)
func (*FileCacheActor) MemoryUsageBytes ¶
func (f *FileCacheActor) MemoryUsageBytes() int
type FileCacheInstantiatePayload ¶
type FileCacheInstantiatePayload struct {
FileSize int
}
FileCacheInstantiatePayload contains the arguments with which the file cache must be instantiated.
type FileCacheModule ¶
type FileCacheModule struct {
// contains filtered or unexported fields
}
FileCacheModule implements a file caching module that deduplicates fetches for byte range portions of a file and then caches chunks of data in-memory for subsequent requests. It's designed to drastically reduce load on the source of truth for the file.
func NewFileCacheModule ¶
func NewFileCacheModule( chunkSize int, fetchSize int, fetcher Fetcher, chunkCache ChunkCache, ) *FileCacheModule
NewFileCacheModule creates a new FileCacheModule.
func (*FileCacheModule) Instantiate ¶
func (f *FileCacheModule) Instantiate( ctx context.Context, reference types.ActorReferenceVirtual, payload []byte, host virtual.HostCapabilities, ) (virtual.Actor, error)
type GetRangeRequest ¶
type GetRangeRequest struct { StartOffset int `json:"start_offset"` EndOffset int `json:"end_offset"` }
GetRangeRequest contains the arguments for a request to read a range of bytes from the file that the FileCacheActor is caching.