cache

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cache is the Cache port: a disposable local store for upstream responses and derived data. Deleting it never loses data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get returns the entry for key; ok is false when there is none.
	Get(ctx context.Context, key string) (e Entry, ok bool, err error)
	Put(ctx context.Context, key string, e Entry) error
	// Delete removes the entry for key, if any.
	Delete(ctx context.Context, key string) error
	// DeletePrefix removes every entry whose key starts with prefix.
	DeletePrefix(ctx context.Context, prefix string) error

	// RecordVisit notes that pr was opened, replacing any earlier visit.
	RecordVisit(ctx context.Context, v Visit) error
	// RecentVisits returns up to limit visits, most recent first.
	RecentVisits(ctx context.Context, limit int) ([]Visit, error)
	// DeleteVisit removes pr from the recent visits, if it is there.
	DeleteVisit(ctx context.Context, pr domain.PRRef) error
}

Cache stores entries by key, and the PRs recently opened.

type Entry

type Entry struct {
	Value     []byte
	ETag      string
	FetchedAt time.Time
}

Entry is a cached value with the validator it was served with.

type Memory

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

Memory is an in-memory Cache for tests.

func NewMemory

func NewMemory() *Memory

func (*Memory) Delete

func (m *Memory) Delete(_ context.Context, key string) error

func (*Memory) DeletePrefix

func (m *Memory) DeletePrefix(_ context.Context, prefix string) error

func (*Memory) DeleteVisit

func (m *Memory) DeleteVisit(_ context.Context, pr domain.PRRef) error

func (*Memory) Get

func (m *Memory) Get(_ context.Context, key string) (Entry, bool, error)

func (*Memory) Keys

func (m *Memory) Keys() []string

Keys returns the keys of every entry, for tests.

func (*Memory) Put

func (m *Memory) Put(_ context.Context, key string, e Entry) error

func (*Memory) RecentVisits

func (m *Memory) RecentVisits(_ context.Context, limit int) ([]Visit, error)

func (*Memory) RecordVisit

func (m *Memory) RecordVisit(_ context.Context, v Visit) error

type Visit

type Visit struct {
	PR        domain.PRRef
	Title     string
	VisitedAt time.Time
}

Visit records a PR opened in Scrutiny, for the Dashboard.

Directories

Path Synopsis
Package sqlite is the Cache adapter backed by a sqlite file, normally $XDG_STATE_HOME/scrutiny/cache.db.
Package sqlite is the Cache adapter backed by a sqlite file, normally $XDG_STATE_HOME/scrutiny/cache.db.

Jump to

Keyboard shortcuts

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