cache

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheStats

type CacheStats struct {
	TotalSize   int64 // Total size of all cached layers
	LayerCount  int   // Number of cached layers
	CacheHits   int64 // Number of cache hits (not persisted)
	CacheMisses int64 // Number of cache misses (not persisted)
	LastPruneAt time.Time
}

CacheStats contains statistics about the cache

type LayerCache

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

LayerCache manages the local layer cache

func NewLayerCache

func NewLayerCache(enabled bool) (*LayerCache, error)

NewLayerCache creates a new layer cache

func (*LayerCache) Clean

func (lc *LayerCache) Clean() error

Clean removes all cached layers

func (*LayerCache) Exists

func (lc *LayerCache) Exists(diffID string) bool

Exists checks if a layer exists in the cache

func (*LayerCache) Get

func (lc *LayerCache) Get(diffID string) (io.ReadCloser, error)

Get retrieves a layer from the cache

func (*LayerCache) GetStats

func (lc *LayerCache) GetStats() *CacheStats

GetStats returns cache statistics

func (*LayerCache) List

func (lc *LayerCache) List() []*LayerMetadata

List returns all cached layers

func (*LayerCache) Prune

func (lc *LayerCache) Prune(maxAge time.Duration) (int, int64, error)

Prune removes layers that haven't been accessed in maxAge

func (*LayerCache) Put

func (lc *LayerCache) Put(diffID string, reader io.Reader, imageRef string, size int64) error

Put saves a layer to the cache

type LayerMetadata

type LayerMetadata struct {
	DiffID     string    `json:"diffid"`      // Uncompressed digest (cache key)
	Digest     string    `json:"digest"`      // Compressed digest
	Size       int64     `json:"size"`        // Uncompressed size
	ImageRef   string    `json:"image_ref"`   // Source image reference (e.g., "alpine:3.20")
	LastAccess time.Time `json:"last_access"` // Last time this layer was accessed
	CreatedAt  time.Time `json:"created_at"`  // When this layer was first cached
}

LayerMetadata contains metadata about a cached layer

Jump to

Keyboard shortcuts

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