cache

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package cache provides a filesystem-backed cache for debuginfod artifacts.

DiskCache wraps a debuginfod.Client and turns its streaming responses into *os.File handles suitable for random-access reads.

On-disk layout under the root directory:

<buildID>/debuginfo
<buildID>/executable
<buildID>/section/<escaped-name>
<buildID>/source/<escaped-seg>/<escaped-seg>/...

Writes are atomic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiskCache

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

DiskCache caches debuginfod artifacts on the local filesystem.

func NewDiskCache

func NewDiskCache(opts DiskCacheOptions) (*DiskCache, error)

func (*DiskCache) Close

func (c *DiskCache) Close() error

func (*DiskCache) Delete

func (c *DiskCache) Delete(_ context.Context, k key.Key) error

Delete removes the cached artifact for k and best-effort prunes empty parent directories. Returns nil if the artifact is not cached.

func (*DiskCache) Get

func (c *DiskCache) Get(ctx context.Context, k key.Key) (*os.File, error)

Get returns an *os.File for the artifact identified by k, fetching and caching it on a miss.

type DiskCacheOptions

type DiskCacheOptions struct {
	// Client fetches artifacts on a miss. Required.
	Client Fetcher
	// Dir is the root directory for cached artifacts. Required.
	// Created if it does not already exist.
	Dir string
}

type Fetcher

type Fetcher interface {
	Fetch(ctx context.Context, k key.Key) (io.ReadCloser, error)
}

Fetcher provides debuginfod artifacts to a DiskCache on a miss. *debuginfod.Client implements Fetcher. Implement it yourself to back the cache with a custom source such as a test stub or an alternative transport.

Jump to

Keyboard shortcuts

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