cache

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package cache manages the local caching of repositories and skills.

Index

Constants

View Source
const DefaultTTL = 5 * time.Minute

DefaultTTL is the default cache time-to-live

Variables

This section is empty.

Functions

func GetReposCacheDir added in v0.9.3

func GetReposCacheDir() string

GetReposCacheDir returns the repos cache directory path

Types

type Cache

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

Cache provides file-based caching with TTL

func New

func New(cacheDir string, ttl time.Duration) (*Cache, error)

New creates a new cache instance

func (*Cache) Clear

func (c *Cache) Clear() error

Clear removes all cached entries

func (*Cache) Get

func (c *Cache) Get(key string, v interface{}) bool

Get retrieves a value from the cache if it exists and is not expired

func (*Cache) Set

func (c *Cache) Set(key string, v interface{}) error

Set stores a value in the cache

type Entry added in v1.0.0

type Entry struct {
	Data      json.RawMessage `json:"data"`
	CreatedAt time.Time       `json:"created_at"`
}

Entry represents a cached item with metadata

type RepoInfo added in v0.9.3

type RepoInfo struct {
	Name         string    `json:"name"`
	URL          string    `json:"url"`
	LocalPath    string    `json:"local_path"`
	UpdatedAt    time.Time `json:"updated_at"`
	LastSyncedAt time.Time `json:"last_synced_at"`
	Stars        int       `json:"stars"`
}

RepoInfo represents cached repository metadata

type ReposCache added in v0.9.3

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

ReposCache manages local git repository cache for skill discovery

func NewReposCache added in v0.9.3

func NewReposCache() (*ReposCache, error)

NewReposCache creates a new repos cache instance

func (*ReposCache) CloneOrPull added in v0.9.3

func (c *ReposCache) CloneOrPull(ctx context.Context, repoURL, repoName string) error

CloneOrPull clones a repo if not exists, or pulls if exists

func (*ReposCache) GetCachedRepos added in v0.9.3

func (c *ReposCache) GetCachedRepos() []string

GetCachedRepos returns list of cached repo names

func (*ReposCache) HasRepo added in v0.9.3

func (c *ReposCache) HasRepo(repoName string) bool

HasRepo checks if a repository is cached locally

func (*ReposCache) IsStale added in v1.5.0

func (c *ReposCache) IsStale(repoName string, ttl time.Duration) bool

IsStale checks if a repository's cache is older than the ttl

func (*ReposCache) ListSkills added in v0.9.3

func (c *ReposCache) ListSkills(repoName string) ([]SkillEntry, error)

ListSkills lists all skills in a cached repo

func (*ReposCache) LoadIndex added in v0.9.5

func (c *ReposCache) LoadIndex() ([]RepoInfo, error)

LoadIndex loads the repo index from disk

func (*ReposCache) SaveIndex added in v0.9.3

func (c *ReposCache) SaveIndex() error

SaveIndex saves the current repo index to disk (without stars)

func (*ReposCache) SaveIndexWithStars added in v0.9.5

func (c *ReposCache) SaveIndexWithStars(starCounts map[string]int, urls map[string]string) error

SaveIndexWithStars saves the current repo index to disk with star counts and URLs

func (*ReposCache) SearchSkills added in v0.9.3

func (c *ReposCache) SearchSkills(keyword string) ([]SkillEntry, error)

SearchSkills searches for skills matching keyword in all cached repos

type SkillEntry added in v0.9.3

type SkillEntry struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Path        string `json:"path"`
	RepoName    string `json:"repo_name"`
}

SkillEntry represents a skill found in local cache

Jump to

Keyboard shortcuts

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