cache

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

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
}

Cache provides advanced caching capabilities

func NewCache

func NewCache(basePath string, maxAge time.Duration, maxSize int64) (*Cache, error)

NewCache creates a new cache

func (*Cache) Cleanup

func (c *Cache) Cleanup(ctx context.Context) error

Cleanup removes expired entries and enforces size limits

func (*Cache) Clear

func (c *Cache) Clear() error

Clear removes all items from the cache

func (*Cache) Delete

func (c *Cache) Delete(key string) error

Delete removes an item from the cache

func (*Cache) Get

func (c *Cache) Get(key string) ([]byte, bool)

Get retrieves an item from the cache

func (*Cache) GetCookbook

func (c *Cache) GetCookbook(name, version string) ([]byte, bool)

GetCookbook retrieves a cookbook from the cache

func (*Cache) HitRate

func (c *Cache) HitRate() float64

HitRate returns the cache hit rate as a percentage

func (*Cache) Put

func (c *Cache) Put(key string, data []byte) error

Put stores an item in the cache

func (*Cache) PutCookbook

func (c *Cache) PutCookbook(cookbook *berkshelf.Cookbook, data []byte) error

PutCookbook stores a cookbook in the cache

func (*Cache) Size

func (c *Cache) Size() int64

Size returns the current cache size in bytes

func (*Cache) Stats

func (c *Cache) Stats() *CacheStats

Stats returns cache statistics

type CacheCheckResult

type CacheCheckResult struct {
	CachedCookbooks      []*resolver.ResolvedCookbook
	UncachedRequirements []*resolver.Requirement
	CacheHitCount        int
	CacheMissCount       int
}

CacheCheckResult contains the result of cache checking

type CacheEntry

type CacheEntry struct {
	Key         string    `json:"key"`
	Path        string    `json:"path"`
	Size        int64     `json:"size"`
	CreatedAt   time.Time `json:"created_at"`
	AccessedAt  time.Time `json:"accessed_at"`
	AccessCount int64     `json:"access_count"`
	Checksum    string    `json:"checksum"`
}

CacheEntry represents a cached item with metadata

type CacheStats

type CacheStats struct {
	Hits        int64     `json:"hits"`
	Misses      int64     `json:"misses"`
	Evictions   int64     `json:"evictions"`
	TotalSize   int64     `json:"total_size"`
	LastCleanup time.Time `json:"last_cleanup"`
	// contains filtered or unexported fields
}

CacheStats tracks cache performance metrics

type Installer

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

Installer handles cookbook caching during install operations

func NewInstaller

func NewInstaller(cache *Cache, sourceManager *source.Manager, config *config.Config) *Installer

NewInstaller creates a new cache installer

func (*Installer) CheckCacheForRequirements

func (i *Installer) CheckCacheForRequirements(ctx context.Context, requirements []*resolver.Requirement) (*CacheCheckResult, error)

CheckCacheForRequirements checks which requirements are already cached

func (*Installer) CleanupCache

func (i *Installer) CleanupCache(ctx context.Context) error

CleanupCache performs cache cleanup

func (*Installer) DownloadAndCache

func (i *Installer) DownloadAndCache(ctx context.Context, resolution *resolver.Resolution) error

DownloadAndCache downloads and caches resolved cookbooks with progress reporting

func (*Installer) GetCacheStats

func (i *Installer) GetCacheStats() *CacheStats

GetCacheStats returns cache statistics

Jump to

Keyboard shortcuts

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