lazyloader

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LazyDocument

type LazyDocument struct {
	// contains filtered or unexported fields
}

LazyDocument represents a document that is loaded on demand

func NewLazyDocument

func NewLazyDocument(path string) *LazyDocument

NewLazyDocument creates a new lazy document

func NewLazyDocumentWithLoader

func NewLazyDocumentWithLoader(path string, loader func() ([]byte, error)) *LazyDocument

NewLazyDocumentWithLoader creates a new lazy document with a custom loader

func (*LazyDocument) IsLoaded

func (d *LazyDocument) IsLoaded() bool

IsLoaded returns whether the document is loaded

func (*LazyDocument) Load

func (d *LazyDocument) Load() ([]byte, error)

Load loads the document content

func (*LazyDocument) LoadWithContext

func (d *LazyDocument) LoadWithContext(ctx context.Context) ([]byte, error)

LoadWithContext loads the document with context cancellation

func (*LazyDocument) Path

func (d *LazyDocument) Path() string

Path returns the document path

func (*LazyDocument) Reader

func (d *LazyDocument) Reader() (io.Reader, error)

Reader returns an io.Reader for the document

func (*LazyDocument) Size

func (d *LazyDocument) Size() (int64, error)

Size returns the document size (requires loading metadata)

func (*LazyDocument) Unload

func (d *LazyDocument) Unload()

Unload unloads the document content to free memory

type LazyDocumentManager

type LazyDocumentManager struct {
	// contains filtered or unexported fields
}

LazyDocumentManager manages multiple lazy documents

func NewLazyDocumentManager

func NewLazyDocumentManager(maxSize int64) *LazyDocumentManager

NewLazyDocumentManager creates a new lazy document manager

func (*LazyDocumentManager) AddDocument

func (m *LazyDocumentManager) AddDocument(path string) *LazyDocument

AddDocument adds a document to the manager

func (*LazyDocumentManager) GetDocument

func (m *LazyDocumentManager) GetDocument(path string) (*LazyDocument, bool)

GetDocument gets a document from the manager

func (*LazyDocumentManager) GetMemoryUsage

func (m *LazyDocumentManager) GetMemoryUsage() int64

GetMemoryUsage returns the current memory usage

func (*LazyDocumentManager) LoadDocument

func (m *LazyDocumentManager) LoadDocument(path string) ([]byte, error)

LoadDocument loads a document and tracks memory usage

func (*LazyDocumentManager) RemoveDocument

func (m *LazyDocumentManager) RemoveDocument(path string)

RemoveDocument removes a document from the manager

func (*LazyDocumentManager) UnloadAll

func (m *LazyDocumentManager) UnloadAll()

UnloadAll unloads all documents

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL