cache

package
v0.0.0-...-d4ea3c3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// GetRepos retrieves cached repositories
	GetRepos(ctx context.Context, org string) ([]*github.Repository, error)
	// SetRepos caches repositories
	SetRepos(ctx context.Context, org string, repos []*github.Repository) error

	// GetCODEOWNERS retrieves cached CODEOWNERS file
	GetCODEOWNERS(ctx context.Context, owner, repo string) ([]byte, error)
	// SetCODEOWNERS caches CODEOWNERS file
	SetCODEOWNERS(ctx context.Context, owner, repo string, content []byte) error

	// GetPRs retrieves cached PRs for a repository, filtered by time window
	GetPRs(ctx context.Context, owner, repo string, since, until time.Time) ([]*github.PullRequest, error)
	// SetPRs caches PRs for a repository (stores individual PRs by ID)
	SetPRs(ctx context.Context, owner, repo string, prs []*github.PullRequest) error

	// GetPRFiles retrieves cached PR files
	GetPRFiles(ctx context.Context, owner, repo string, prNumber int) ([]*github.CommitFile, error)
	// SetPRFiles caches PR files
	SetPRFiles(ctx context.Context, owner, repo string, prNumber int, files []*github.CommitFile) error

	// Invalidate invalidates all cache entries
	Invalidate(ctx context.Context) error
	// InvalidateRepo invalidates cache for a specific repository
	InvalidateRepo(ctx context.Context, owner, repo string) error

	// Close closes the cache
	Close() error
}

Cache interface for different cache backends

func NewCache

func NewCache(backend, sqlitePath, jsonDir string, ttl time.Duration, ignoreTTL bool, logger *zap.Logger) (Cache, error)

NewCache creates a new cache instance based on backend type

type CacheEntry

type CacheEntry struct {
	Data      interface{} `json:"data"`
	Timestamp time.Time   `json:"timestamp"`
	TTL       time.Duration
}

CacheEntry represents a cached entry with metadata

func (*CacheEntry) IsExpired

func (e *CacheEntry) IsExpired(ttl time.Duration) bool

IsExpired checks if a cache entry is expired

type JSONCache

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

JSONCache implements cache using JSON files

func NewJSONCache

func NewJSONCache(baseDir string, ttl time.Duration, ignoreTTL bool, logger *zap.Logger) (*JSONCache, error)

NewJSONCache creates a new JSON file cache

func (*JSONCache) Close

func (c *JSONCache) Close() error

Close closes the cache

func (*JSONCache) GetCODEOWNERS

func (c *JSONCache) GetCODEOWNERS(ctx context.Context, owner, repo string) ([]byte, error)

GetCODEOWNERS retrieves cached CODEOWNERS file

func (*JSONCache) GetPRFiles

func (c *JSONCache) GetPRFiles(ctx context.Context, owner, repo string, prNumber int) ([]*github.CommitFile, error)

GetPRFiles retrieves cached PR files

func (*JSONCache) GetPRs

func (c *JSONCache) GetPRs(ctx context.Context, owner, repo string, since, until time.Time) ([]*github.PullRequest, error)

GetPRs retrieves cached PRs for a repository, filtered by time window

func (*JSONCache) GetRepos

func (c *JSONCache) GetRepos(ctx context.Context, org string) ([]*github.Repository, error)

GetRepos retrieves cached repositories

func (*JSONCache) Invalidate

func (c *JSONCache) Invalidate(ctx context.Context) error

Invalidate invalidates all cache entries

func (*JSONCache) InvalidateRepo

func (c *JSONCache) InvalidateRepo(ctx context.Context, owner, repo string) error

InvalidateRepo invalidates cache for a specific repository

func (*JSONCache) SetCODEOWNERS

func (c *JSONCache) SetCODEOWNERS(ctx context.Context, owner, repo string, content []byte) error

SetCODEOWNERS caches CODEOWNERS file

func (*JSONCache) SetPRFiles

func (c *JSONCache) SetPRFiles(ctx context.Context, owner, repo string, prNumber int, files []*github.CommitFile) error

SetPRFiles caches PR files

func (*JSONCache) SetPRs

func (c *JSONCache) SetPRs(ctx context.Context, owner, repo string, prs []*github.PullRequest) error

SetPRs caches PRs for a repository (stores individual PRs by ID)

func (*JSONCache) SetRepos

func (c *JSONCache) SetRepos(ctx context.Context, org string, repos []*github.Repository) error

SetRepos caches repositories

type SQLiteCache

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

SQLiteCache implements cache using SQLite

func NewSQLiteCache

func NewSQLiteCache(dbPath string, ttl time.Duration, ignoreTTL bool, logger *zap.Logger) (*SQLiteCache, error)

NewSQLiteCache creates a new SQLite cache

func (*SQLiteCache) Close

func (c *SQLiteCache) Close() error

Close closes the cache

func (*SQLiteCache) GetCODEOWNERS

func (c *SQLiteCache) GetCODEOWNERS(ctx context.Context, owner, repo string) ([]byte, error)

GetCODEOWNERS retrieves cached CODEOWNERS file

func (*SQLiteCache) GetPRFiles

func (c *SQLiteCache) GetPRFiles(ctx context.Context, owner, repo string, prNumber int) ([]*github.CommitFile, error)

GetPRFiles retrieves cached PR files

func (*SQLiteCache) GetPRs

func (c *SQLiteCache) GetPRs(ctx context.Context, owner, repo string, since, until time.Time) ([]*github.PullRequest, error)

GetPRs retrieves cached PRs for a repository, filtered by time window

func (*SQLiteCache) GetRepos

func (c *SQLiteCache) GetRepos(ctx context.Context, org string) ([]*github.Repository, error)

GetRepos retrieves cached repositories

func (*SQLiteCache) Invalidate

func (c *SQLiteCache) Invalidate(ctx context.Context) error

Invalidate invalidates all cache entries

func (*SQLiteCache) InvalidateRepo

func (c *SQLiteCache) InvalidateRepo(ctx context.Context, owner, repo string) error

InvalidateRepo invalidates cache for a specific repository

func (*SQLiteCache) SetCODEOWNERS

func (c *SQLiteCache) SetCODEOWNERS(ctx context.Context, owner, repo string, content []byte) error

SetCODEOWNERS caches CODEOWNERS file

func (*SQLiteCache) SetPRFiles

func (c *SQLiteCache) SetPRFiles(ctx context.Context, owner, repo string, prNumber int, files []*github.CommitFile) error

SetPRFiles caches PR files

func (*SQLiteCache) SetPRs

func (c *SQLiteCache) SetPRs(ctx context.Context, owner, repo string, prs []*github.PullRequest) error

SetPRs caches PRs for a repository (stores individual PRs by ID)

func (*SQLiteCache) SetRepos

func (c *SQLiteCache) SetRepos(ctx context.Context, org string, repos []*github.Repository) error

SetRepos caches repositories

Jump to

Keyboard shortcuts

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