Documentation
¶
Overview ¶
Package cache persists GitHub Actions run timings and other API responses to disk and memory so repeated TUI and CLI invocations avoid refetching.
Index ¶
- func FilterRunsByCommit(runs []github.RunTiming, commitSHA string) []github.RunTiming
- func FilterRunsByConclusion(runs []github.RunTiming, conclusion string) []github.RunTiming
- func GetLatestRunPerWorkflow(runs []github.RunTiming) []github.RunTiming
- func GetRunsInDateRange(runs []github.RunTiming, since, until time.Time) []github.RunTiming
- func MergeRuns(existing, newRuns []github.RunTiming) []github.RunTiming
- type GHAPerfCache
- type GHAPerfCacheManager
- func (m *GHAPerfCacheManager) Clear(owner, repo string) error
- func (m *GHAPerfCacheManager) ClearAll() error
- func (m *GHAPerfCacheManager) GetCachedRunIDs(owner, repo string) (map[int]bool, error)
- func (m *GHAPerfCacheManager) ListCaches() ([]string, error)
- func (m *GHAPerfCacheManager) Load(owner, repo string) (*GHAPerfCache, error)
- func (m *GHAPerfCacheManager) Save(owner, repo string, cache *GHAPerfCache) error
- func (m *GHAPerfCacheManager) Stats(owner, repo string) (int, time.Time, error)
- type MemoryManager
- func (m *MemoryManager) CleanExpired() error
- func (m *MemoryManager) Clear() error
- func (*MemoryManager) Close() error
- func (m *MemoryManager) Delete(key string) error
- func (m *MemoryManager) Get(key string, dest any) (bool, error)
- func (m *MemoryManager) Set(key string, value any) error
- func (m *MemoryManager) Stats() (int, int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterRunsByCommit ¶
FilterRunsByCommit returns the runs matching commitSHA, exactly or by a shared 7-character prefix. An empty commitSHA returns runs unchanged.
func FilterRunsByConclusion ¶
FilterRunsByConclusion returns the runs with the given conclusion. An empty conclusion returns runs unchanged.
func GetLatestRunPerWorkflow ¶
GetLatestRunPerWorkflow returns each workflow's most recently created run, sorted by workflow name.
func GetRunsInDateRange ¶
GetRunsInDateRange returns the runs created within [since, until]. A zero since or until leaves that bound unenforced.
Types ¶
type GHAPerfCache ¶
type GHAPerfCache struct {
UpdatedAt time.Time `json:"updated_at"`
Repo string `json:"repo"`
Runs []github.RunTiming `json:"runs"`
}
GHAPerfCache holds a repository's cached GitHub Actions run timings.
type GHAPerfCacheManager ¶
type GHAPerfCacheManager struct {
// contains filtered or unexported fields
}
GHAPerfCacheManager reads and writes GHAPerfCache files on disk, one JSON file per repository under its cache directory.
func NewGHAPerfCacheManager ¶
func NewGHAPerfCacheManager(cacheDir string) (*GHAPerfCacheManager, error)
NewGHAPerfCacheManager creates the cache directory (defaulting to ~/.cache/gh-sweep/gha-perf when cacheDir is empty) and returns a manager for it.
func (*GHAPerfCacheManager) Clear ¶
func (m *GHAPerfCacheManager) Clear(owner, repo string) error
Clear removes owner/repo's cache file, treating a missing file as success.
func (*GHAPerfCacheManager) ClearAll ¶
func (m *GHAPerfCacheManager) ClearAll() error
ClearAll removes every cache file in the manager's cache directory, treating a missing directory as success.
func (*GHAPerfCacheManager) GetCachedRunIDs ¶
func (m *GHAPerfCacheManager) GetCachedRunIDs(owner, repo string) (map[int]bool, error)
GetCachedRunIDs returns the set of run IDs currently cached for owner/repo.
func (*GHAPerfCacheManager) ListCaches ¶
func (m *GHAPerfCacheManager) ListCaches() ([]string, error)
ListCaches returns the owner_repo identifiers of every cache file in the manager's cache directory.
func (*GHAPerfCacheManager) Load ¶
func (m *GHAPerfCacheManager) Load(owner, repo string) (*GHAPerfCache, error)
Load reads owner/repo's cache file, returning an empty GHAPerfCache when none exists yet.
func (*GHAPerfCacheManager) Save ¶
func (m *GHAPerfCacheManager) Save(owner, repo string, cache *GHAPerfCache) error
Save writes cache to owner/repo's cache file, stamping its UpdatedAt and Repo fields first.
type MemoryManager ¶
type MemoryManager struct {
// contains filtered or unexported fields
}
MemoryManager implements an in-memory cache (temporary, will use SQLite later).
func NewMemoryManager ¶
func NewMemoryManager(ttl time.Duration) *MemoryManager
NewMemoryManager creates a new in-memory cache manager.
func (*MemoryManager) CleanExpired ¶
func (m *MemoryManager) CleanExpired() error
CleanExpired removes all expired entries.
func (*MemoryManager) Clear ¶
func (m *MemoryManager) Clear() error
Clear removes all entries from the cache.
func (*MemoryManager) Close ¶
func (*MemoryManager) Close() error
Close does nothing for memory cache but implements the interface.
func (*MemoryManager) Delete ¶
func (m *MemoryManager) Delete(key string) error
Delete removes a value from the cache.
func (*MemoryManager) Get ¶
func (m *MemoryManager) Get(key string, dest any) (bool, error)
Get retrieves a value from the cache.