cache

package
v0.0.0-...-bda2491 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartPruner

func StartPruner(ctx context.Context, store *Store, interval time.Duration)

StartPruner starts a background goroutine that prunes expired cache entries.

Types

type Config

type Config struct {
	Enabled       bool
	TTL           time.Duration
	PruneInterval time.Duration
	MaxEntries    int
}

Config holds cache configuration from environment.

func ConfigFromEnv

func ConfigFromEnv() Config

ConfigFromEnv reads cache configuration from environment variables.

type Entry

type Entry struct {
	Hash             string
	JobID            uuid.UUID
	TaskName         string
	Result           string
	Output           map[string]string
	BranchSelections []string
	RunID            uuid.UUID
	TaskRunID        uuid.UUID
	CreatedAt        time.Time
	ExpiresAt        *time.Time
}

Entry represents a cached task result.

type HashInput

type HashInput struct {
	JobAlias           string
	TaskName           string
	Image              string
	Command            []string
	Env                map[string]string
	WorkDir            string
	Mounts             []container.Mount
	PredecessorHashes  []string
	PredecessorOutputs map[string]map[string]string
	RunParams          map[string]string
	CacheVersion       int
}

HashInput contains all fields that contribute to a task's identity hash.

func (HashInput) Compute

func (h HashInput) Compute() string

Compute returns the SHA-256 hex digest of the canonicalized input.

type Store

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

Store provides cache operations backed by GORM.

func NewStore

func NewStore(db *gorm.DB) *Store

NewStore creates a new cache store.

func (*Store) Get

func (s *Store) Get(hash string) (*Entry, bool, error)

Get retrieves a cache entry by hash. Returns nil, false, nil if not found or expired.

func (*Store) Invalidate

func (s *Store) Invalidate(jobID uuid.UUID, taskName string) error

Invalidate removes cache entries for a specific task.

func (*Store) InvalidateJob

func (s *Store) InvalidateJob(jobID uuid.UUID) error

InvalidateJob removes all cache entries for a job.

func (*Store) ListByJob

func (s *Store) ListByJob(jobID uuid.UUID) ([]Entry, error)

ListByJob returns all cache entries for a job.

func (*Store) Prune

func (s *Store) Prune() (int, error)

Prune removes expired entries. Returns count of deleted entries.

func (*Store) Put

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

Put stores a cache entry.

Jump to

Keyboard shortcuts

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