cache

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: EUPL-1.2 Imports: 5 Imported by: 0

Documentation

Overview

Package cache provides a file-based cache for GitHub API responses.

Index

Constants

View Source
const DefaultTTL = 1 * time.Hour

DefaultTTL is the default cache expiry time.

Variables

This section is empty.

Functions

func GitHubRepoKey

func GitHubRepoKey(org, repo string) string

GitHubRepoKey returns the cache key for a specific repo's metadata.

func GitHubReposKey

func GitHubReposKey(org string) string

GitHubReposKey returns the cache key for an org's repo list.

Types

type Cache

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

Cache represents a file-based cache.

func New

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

New creates a new cache instance. If baseDir is empty, uses .core/cache in current directory

func (*Cache) Age

func (c *Cache) Age(key string) time.Duration

Age returns how old a cached item is, or -1 if not cached.

func (*Cache) Clear

func (c *Cache) Clear() error

Clear removes all cached items.

func (*Cache) Delete

func (c *Cache) Delete(key string) error

Delete removes an item from the cache.

func (*Cache) Get

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

Get retrieves a cached item if it exists and hasn't expired.

func (*Cache) Path

func (c *Cache) Path(key string) string

Path returns the full path for a cache key.

func (*Cache) Set

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

Set stores an item in the cache.

type Entry

type Entry struct {
	Data      json.RawMessage `json:"data"`
	CachedAt  time.Time       `json:"cached_at"`
	ExpiresAt time.Time       `json:"expires_at"`
}

Entry represents a cached item with metadata.

Jump to

Keyboard shortcuts

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