cache

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cache manages local cached team configs.

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 manages local cached team configs.

func New

func New(paths *config.Paths) *Cache

New creates a cache manager.

func (*Cache) CacheDir

func (c *Cache) CacheDir() string

CacheDir returns the cache directory path.

func (*Cache) Clear

func (c *Cache) Clear(owner, repo string) error

Clear removes cached content for a repo. Returns nil even if files don't exist (idempotent operation).

func (*Cache) Exists

func (c *Cache) Exists(owner, repo string) bool

Exists checks if cache exists for a repo.

func (*Cache) GetMetadata

func (c *Cache) GetMetadata(owner, repo string) (*Metadata, error)

GetMetadata returns only the metadata without reading content.

func (*Cache) ListCached

func (c *Cache) ListCached() ([]string, error)

ListCached returns all cached repo identifiers.

func (*Cache) Read

func (c *Cache) Read(owner, repo string) (content string, meta *Metadata, err error)

Read returns cached content and metadata, or error if not cached.

func (*Cache) Write

func (c *Cache) Write(owner, repo, content string, meta *Metadata) error

Write stores content and metadata.

type Metadata

type Metadata struct {
	Owner       string    `json:"owner"`
	Repo        string    `json:"repo"`
	ETag        string    `json:"etag,omitempty"`
	SHA         string    `json:"sha,omitempty"`
	LastFetched time.Time `json:"last_fetched"`
}

Metadata stores cache state for conditional fetching.

func (*Metadata) Age

func (m *Metadata) Age() string

Age returns human-readable age string.

func (*Metadata) IsStale

func (m *Metadata) IsStale(ttl time.Duration) bool

IsStale returns true if cache is at or older than the TTL.

func (*Metadata) RepoString

func (m *Metadata) RepoString() string

RepoString returns "owner/repo" format.

Jump to

Keyboard shortcuts

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