Help us shape the future of Go! Take the 2026 Go Developer Survey

artwork

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxCacheBytes and DefaultMaxCacheFiles keep the persistent
	// artwork cache bounded for household deployments without adding another
	// required runtime setting.
	DefaultMaxCacheBytes int64 = 1 << 30
	DefaultMaxCacheFiles       = 25_000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	Data        []byte
	ContentType string
	Status      string
	MaxAge      time.Duration
}

type Cache

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

func NewCache

func NewCache(root string, options ...Option) (*Cache, error)

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, mbid string) Asset

func (*Cache) Prune added in v0.20.0

func (c *Cache) Prune(ctx context.Context, maxBytes int64, maxFiles int) (PruneStats, error)

Prune removes stale entries and then oldest entries until both cache limits are satisfied. Files are written atomically by refresh, so a directory snapshot is safe to inspect while a fetch is in progress. Temporary files are deliberately ignored and are cleaned up by their writer.

type Option

type Option func(*Cache)

func WithBaseURL

func WithBaseURL(value string) Option

func WithClock

func WithClock(clock func() time.Time) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

type Provider

type Provider interface {
	Get(context.Context, string) Asset
}

type PruneStats added in v0.20.0

type PruneStats struct {
	RemovedFiles int
	RemovedBytes int64
	StaleFiles   int
}

Jump to

Keyboard shortcuts

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