cache

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(reference string) string

GenerateKey generates a cache key from an artifact reference

Types

type Cache

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

Cache provides artifact caching functionality

func NewCache

func NewCache(dir string, maxSize int64, ttl time.Duration, logger hclog.Logger) (*Cache, error)

NewCache creates a new cache instance

func (*Cache) Clean

func (c *Cache) Clean() (int, error)

Clean removes expired cache entries

func (*Cache) Close

func (c *Cache) Close() error

Close closes the cache and releases resources

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, reference string) (*CacheEntry, error)

Get retrieves an artifact from the cache

func (*Cache) List

func (c *Cache) List() ([]*CacheEntry, error)

List returns all cached artifacts

func (*Cache) Put

func (c *Cache) Put(ctx context.Context, reference string, reader io.Reader) (*CacheEntry, error)

Put stores an artifact in the cache

func (*Cache) Remove

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

Remove removes an artifact from the cache

func (*Cache) Size

func (c *Cache) Size() (int64, error)

Size calculates the total size of cached artifacts

type CacheEntry

type CacheEntry struct {
	Key         string    `json:"key"`
	Reference   string    `json:"reference"`
	ContentPath string    `json:"content_path"`
	Size        int64     `json:"size"`
	CreatedAt   time.Time `json:"created_at"`
	AccessedAt  time.Time `json:"accessed_at"`
	AccessCount int       `json:"access_count"`
}

CacheEntry represents a cached artifact

type Store

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

Store provides persistent storage for cache metadata

func NewStore

func NewStore(path string, logger hclog.Logger) (*Store, error)

NewStore creates a new cache store

func (*Store) Close

func (s *Store) Close() error

Close closes the store and saves any pending changes

func (*Store) Delete

func (s *Store) Delete(key string) error

Delete removes a cache entry by key

func (*Store) Get

func (s *Store) Get(key string) (*CacheEntry, error)

Get retrieves a cache entry by key

func (*Store) List

func (s *Store) List() ([]*CacheEntry, error)

List returns all cache entries

func (*Store) Put

func (s *Store) Put(entry *CacheEntry) error

Put stores a cache entry

func (*Store) Update

func (s *Store) Update(entry *CacheEntry) error

Update updates an existing cache entry

Jump to

Keyboard shortcuts

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