reader

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package reader provides a bounded, coalescing cache of immutable decoded chunks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func New

func New(config Config, load func(context.Context, chunk.Ref) ([]byte, error)) (*Cache, error)

func (*Cache) Close

func (c *Cache) Close()

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, ref chunk.Ref) ([]byte, error)

Get never holds a file or cache lock during backend I/O. A caller cancelling its wait does not cancel a shared load needed by another reader. Close owns cancellation and waits for all loads before the backend can be closed.

func (*Cache) Prefetch

func (c *Cache) Prefetch(ref chunk.Ref)

func (*Cache) Snapshot

func (c *Cache) Snapshot() Stats

type Config

type Config struct {
	CacheBytes int64
	Workers    int
	Ahead      int
}

Config controls capacity, load concurrency and sequential read ahead. Callers schedule sequential prefetch; the cache enforces capacity and preserves a load slot for foreground demand.

type Stats

type Stats struct {
	CapacityBytes int64 `json:"capacity_bytes"`
	UsedBytes     int64 `json:"used_bytes"`
	ReservedBytes int64 `json:"reserved_bytes"`
	InFlight      int   `json:"in_flight"`
	Workers       int   `json:"workers"`
	Ahead         int   `json:"ahead"`
	Hits          int64 `json:"hits"`
	Misses        int64 `json:"misses"`
	Coalesced     int64 `json:"coalesced"`
	Prefetches    int64 `json:"prefetches"`
	PrefetchHits  int64 `json:"prefetch_hits"`
	Evictions     int64 `json:"evictions"`
	Errors        int64 `json:"errors"`
}

Stats describes decoded data, separately from the NVMe raw and encoded caches. Prefetch failures are retried normally on a subsequent read.

Jump to

Keyboard shortcuts

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