cache

package
v0.6.11 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlobCache added in v0.6.2

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

BlobCache manages the local blob cache Unlike the old LayerCache, this stores registry blobs directly (compressed) without any decompression/recompression, using digest as the key

func NewBlobCache added in v0.6.2

func NewBlobCache(enabled bool) (*BlobCache, error)

NewBlobCache creates a new blob cache

func (*BlobCache) Clean added in v0.6.2

func (bc *BlobCache) Clean() error

Clean removes all cached blobs

func (*BlobCache) Exists added in v0.6.2

func (bc *BlobCache) Exists(digest string) bool

Exists checks if a blob exists in the cache by digest

func (*BlobCache) Get added in v0.6.2

func (bc *BlobCache) Get(digest string) (io.ReadCloser, error)

Get retrieves a blob from the cache Returns an io.ReadCloser for the compressed blob

func (*BlobCache) GetMetadata added in v0.6.2

func (bc *BlobCache) GetMetadata(digest string) (*BlobMetadata, error)

GetMetadata returns metadata for a blob

func (*BlobCache) GetStats added in v0.6.2

func (bc *BlobCache) GetStats() (totalSize int64, blobCount int)

GetStats returns cache statistics

func (*BlobCache) List added in v0.6.2

func (bc *BlobCache) List() []*BlobMetadata

List returns all cached blobs

func (*BlobCache) Prune added in v0.6.2

func (bc *BlobCache) Prune(maxAge time.Duration) (int, int64, error)

Prune removes blobs that haven't been accessed in maxAge

func (*BlobCache) Put added in v0.6.2

func (bc *BlobCache) Put(digest, diffID string, reader io.Reader, imageRef string) error

Put saves a blob to the cache reader should be the compressed blob data from the registry digest verification is performed during write

type BlobCacheIndex added in v0.6.2

type BlobCacheIndex struct {
	Version   string                   `json:"version"` // Index format version
	Blobs     map[string]*BlobMetadata `json:"blobs"`   // digest -> metadata
	CreatedAt time.Time                `json:"created_at"`
	UpdatedAt time.Time                `json:"updated_at"`
}

BlobCacheIndex contains the index of all cached blobs

type BlobMetadata added in v0.6.2

type BlobMetadata struct {
	Digest     string    `json:"digest"`      // Compressed digest (cache key, with sha256: prefix)
	DiffID     string    `json:"diffid"`      // Uncompressed digest
	Size       int64     `json:"size"`        // Compressed size
	ImageRefs  []string  `json:"image_refs"`  // Source image references (multiple images may share this blob)
	LastAccess time.Time `json:"last_access"` // Last time this blob was accessed
	CreatedAt  time.Time `json:"created_at"`  // When this blob was first cached
}

BlobMetadata contains metadata about a cached blob

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