Documentation
¶
Overview ¶
Package cache provides fine-grained file-level caching for monox.
Package cache provides Google Cloud Storage remote caching for monox.
Package cache provides caching infrastructure for monox.
Package cache provides AWS S3 remote caching for monox.
Index ¶
- type Cache
- type CacheManifest
- type CacheStats
- type DiffCache
- type FileHash
- type FileRef
- type FineGrainedCache
- func (c *FineGrainedCache) CacheTask(project, target string, inputFiles, outputFiles []string, duration int64) error
- func (c *FineGrainedCache) Close() error
- func (c *FineGrainedCache) GetBlob(hash string) ([]byte, error)
- func (c *FineGrainedCache) HasBlob(hash string) bool
- func (c *FineGrainedCache) HashFile(path string) (*FileHash, error)
- func (c *FineGrainedCache) HashFiles(paths []string) ([]FileRef, error)
- func (c *FineGrainedCache) LookupTask(project, target string, inputFiles []string) (*TaskCache, bool, error)
- func (c *FineGrainedCache) Prune(maxAge time.Duration, maxSize int64) error
- func (c *FineGrainedCache) RestoreFile(hash, dstPath string) error
- func (c *FineGrainedCache) RestoreTask(project, target string) error
- func (c *FineGrainedCache) Stats() (*FineGrainedCacheStats, error)
- func (c *FineGrainedCache) StoreBlob(hash string, content []byte) error
- func (c *FineGrainedCache) StoreFile(srcPath string) (string, error)
- type FineGrainedCacheStats
- type GCSCache
- func (c *GCSCache) Close() error
- func (c *GCSCache) Delete(ctx context.Context, hash string) error
- func (c *GCSCache) Get(ctx context.Context, hash string) (*api.CacheEntry, error)
- func (c *GCSCache) Has(ctx context.Context, hash string) (bool, error)
- func (c *GCSCache) Put(ctx context.Context, entry *api.CacheEntry, outputs []string) error
- func (c *GCSCache) RestoreOutputs(ctx context.Context, hash string, projectPath string) error
- type GCSConfig
- type Hasher
- type LocalCache
- func (c *LocalCache) Close() error
- func (c *LocalCache) Delete(ctx context.Context, hash string) error
- func (c *LocalCache) Get(ctx context.Context, hash string) (*api.CacheEntry, error)
- func (c *LocalCache) GetStats() (*CacheStats, error)
- func (c *LocalCache) Has(ctx context.Context, hash string) (bool, error)
- func (c *LocalCache) Prune(ctx context.Context, maxAge time.Duration, maxSize int64) (int, error)
- func (c *LocalCache) Put(ctx context.Context, entry *api.CacheEntry, outputs []string) error
- func (c *LocalCache) RestoreOutputs(ctx context.Context, hash string, projectPath string) error
- type S3Cache
- func (c *S3Cache) Close() error
- func (c *S3Cache) Delete(ctx context.Context, hash string) error
- func (c *S3Cache) Get(ctx context.Context, hash string) (*api.CacheEntry, error)
- func (c *S3Cache) Has(ctx context.Context, hash string) (bool, error)
- func (c *S3Cache) Put(ctx context.Context, entry *api.CacheEntry, outputs []string) error
- func (c *S3Cache) RestoreOutputs(ctx context.Context, hash string, projectPath string) error
- type S3Config
- type TaskCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
Get(ctx context.Context, hash string) (*api.CacheEntry, error)
Put(ctx context.Context, entry *api.CacheEntry, outputs []string) error
Has(ctx context.Context, hash string) (bool, error)
Delete(ctx context.Context, hash string) error
RestoreOutputs(ctx context.Context, hash string, projectPath string) error
Close() error
}
Cache is the interface for cache implementations.
type CacheManifest ¶
type CacheManifest struct {
Version int `json:"version"`
Files map[string]*FileHash `json:"files"`
Tasks map[string]*TaskCache `json:"tasks"`
UpdatedAt time.Time `json:"updatedAt"`
}
CacheManifest tracks all cached files and their relationships.
type CacheStats ¶
type CacheStats struct {
Entries int `json:"entries"`
Size int64 `json:"size"`
OldestTime time.Time `json:"oldest"`
NewestTime time.Time `json:"newest"`
}
CacheStats holds cache statistics.
type DiffCache ¶
type DiffCache struct {
// contains filtered or unexported fields
}
DiffCache provides incremental caching based on file diffs.
func NewDiffCache ¶
func NewDiffCache(cache *FineGrainedCache) *DiffCache
NewDiffCache creates a diff-based cache.
func (*DiffCache) GetAffectedTasks ¶
GetAffectedTasks returns tasks affected by file changes.
func (*DiffCache) MarkChanged ¶
MarkChanged marks a file as changed.
func (*DiffCache) MarkDeleted ¶
MarkDeleted marks a file as deleted.
type FileHash ¶
type FileHash struct {
Path string `json:"path"`
ContentHash string `json:"contentHash"`
ModTime time.Time `json:"modTime"`
Size int64 `json:"size"`
Dependencies []string `json:"dependencies,omitempty"`
}
FileHash stores hash information for a single file.
type FineGrainedCache ¶
type FineGrainedCache struct {
// contains filtered or unexported fields
}
FineGrainedCache provides file-level caching for improved cache hits.
func NewFineGrainedCache ¶
func NewFineGrainedCache(cacheDir, workspaceRoot string) (*FineGrainedCache, error)
NewFineGrainedCache creates a new fine-grained cache.
func (*FineGrainedCache) CacheTask ¶
func (c *FineGrainedCache) CacheTask(project, target string, inputFiles, outputFiles []string, duration int64) error
CacheTask stores a task's outputs with file-level granularity.
func (*FineGrainedCache) GetBlob ¶
func (c *FineGrainedCache) GetBlob(hash string) ([]byte, error)
GetBlob retrieves content by hash.
func (*FineGrainedCache) HasBlob ¶
func (c *FineGrainedCache) HasBlob(hash string) bool
HasBlob checks if a blob exists.
func (*FineGrainedCache) HashFile ¶
func (c *FineGrainedCache) HashFile(path string) (*FileHash, error)
HashFile computes the hash of a file with caching.
func (*FineGrainedCache) HashFiles ¶
func (c *FineGrainedCache) HashFiles(paths []string) ([]FileRef, error)
HashFiles computes hashes for multiple files in parallel.
func (*FineGrainedCache) LookupTask ¶
func (c *FineGrainedCache) LookupTask(project, target string, inputFiles []string) (*TaskCache, bool, error)
LookupTask checks if a task can be restored from cache.
func (*FineGrainedCache) Prune ¶
func (c *FineGrainedCache) Prune(maxAge time.Duration, maxSize int64) error
Prune removes old cache entries.
func (*FineGrainedCache) RestoreFile ¶
func (c *FineGrainedCache) RestoreFile(hash, dstPath string) error
RestoreFile restores a file from cache.
func (*FineGrainedCache) RestoreTask ¶
func (c *FineGrainedCache) RestoreTask(project, target string) error
RestoreTask restores outputs from cache.
func (*FineGrainedCache) Stats ¶
func (c *FineGrainedCache) Stats() (*FineGrainedCacheStats, error)
Stats returns cache statistics.
type FineGrainedCacheStats ¶
type FineGrainedCacheStats struct {
TotalFiles int `json:"totalFiles"`
TotalBlobs int `json:"totalBlobs"`
TotalTasks int `json:"totalTasks"`
BlobSizeBytes int64 `json:"blobSizeBytes"`
HitRate float64 `json:"hitRate"`
MissRate float64 `json:"missRate"`
OldestEntry time.Time `json:"oldestEntry"`
NewestEntry time.Time `json:"newestEntry"`
}
FineGrainedCacheStats provides fine-grained cache statistics.
type GCSCache ¶
type GCSCache struct {
// contains filtered or unexported fields
}
GCSCache implements remote caching using Google Cloud Storage.
func NewGCSCache ¶
NewGCSCache creates a new GCS cache client.
type GCSConfig ¶
type GCSConfig struct {
Bucket string
Prefix string
Project string
CredentialsFile string
CredentialsJSON string
ReadOnly bool
}
GCSConfig holds GCS cache configuration.
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher computes cache keys for tasks.
type LocalCache ¶
type LocalCache struct {
// contains filtered or unexported fields
}
LocalCache implements filesystem-based caching.
func NewLocalCache ¶
func NewLocalCache(cacheDir, workspaceRoot string) (*LocalCache, error)
NewLocalCache creates a new local filesystem cache.
func (*LocalCache) Delete ¶
func (c *LocalCache) Delete(ctx context.Context, hash string) error
Delete removes a cache entry.
func (*LocalCache) Get ¶
func (c *LocalCache) Get(ctx context.Context, hash string) (*api.CacheEntry, error)
Get retrieves a cache entry.
func (*LocalCache) GetStats ¶
func (c *LocalCache) GetStats() (*CacheStats, error)
GetStats returns cache statistics.
func (*LocalCache) Put ¶
func (c *LocalCache) Put(ctx context.Context, entry *api.CacheEntry, outputs []string) error
Put stores a cache entry with outputs.
func (*LocalCache) RestoreOutputs ¶
RestoreOutputs restores cached outputs to the project directory.
type S3Cache ¶
type S3Cache struct {
// contains filtered or unexported fields
}
S3Cache implements remote caching using AWS S3.
func NewS3Cache ¶
NewS3Cache creates a new S3 cache client.
type S3Config ¶
type S3Config struct {
Bucket string
Region string
Prefix string
Endpoint string
AccessKeyID string
SecretAccessKey string
ReadOnly bool
}
S3Config holds S3 cache configuration.
type TaskCache ¶
type TaskCache struct {
Project string `json:"project"`
Target string `json:"target"`
InputHash string `json:"inputHash"`
OutputHash string `json:"outputHash"`
InputFiles []FileRef `json:"inputFiles"`
OutputFiles []FileRef `json:"outputFiles"`
Duration int64 `json:"durationMs"`
CachedAt time.Time `json:"cachedAt"`
}
TaskCache stores task-level cache with file granularity.