cache

package
v0.0.0-...-72f1ef6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package cache provides thread information caching for bot operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitPRCache

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

CommitPRCache provides in-memory caching of commit SHA → PR mappings. This allows quick lookup when check events arrive with just a commit SHA, avoiding expensive GitHub API calls for recently-seen PRs.

func NewCommitPRCache

func NewCommitPRCache() *CommitPRCache

NewCommitPRCache creates a new CommitPRCache with initialized maps.

func (*CommitPRCache) FindPRsForCommit

func (cpc *CommitPRCache) FindPRsForCommit(owner, repo, commitSHA string) []int

FindPRsForCommit finds PRs in a repo that match the given commit SHA. Returns PR numbers if found in recent cache (last 10 minutes), nil otherwise.

func (*CommitPRCache) MostRecentPR

func (cpc *CommitPRCache) MostRecentPR(owner, repo string) int

MostRecentPR returns the most recently updated PR number for a repo from the cache. Returns 0 if no recent PRs are cached for this repo.

func (*CommitPRCache) RecordPR

func (cpc *CommitPRCache) RecordPR(owner, repo string, prNumber int, headSHA string)

RecordPR records a PR's head commit SHA for commit→PR lookups. Entries are kept for 10 minutes to handle check events that arrive shortly after PR events.

type CommitPREntry

type CommitPREntry struct {
	UpdatedAt time.Time
	HeadSHA   string
	PRNumber  int
}

CommitPREntry caches recent commit→PR mappings for fast lookup.

type ThreadCache

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

ThreadCache manages PR thread IDs for a workspace.

func New

func New() *ThreadCache

New creates a new ThreadCache with initialized maps.

func (*ThreadCache) Cleanup

func (tc *ThreadCache) Cleanup(maxAge time.Duration)

Cleanup removes entries older than the specified age. This prevents unbounded memory growth for closed/merged PRs.

func (*ThreadCache) Get

func (tc *ThreadCache) Get(prKey string) (ThreadInfo, bool)

Get retrieves thread info for a PR.

func (*ThreadCache) IsCreating

func (tc *ThreadCache) IsCreating(prKey string) bool

IsCreating checks if a PR is currently being created.

func (*ThreadCache) MarkCreating

func (tc *ThreadCache) MarkCreating(prKey string) bool

MarkCreating marks a PR as currently being created to prevent duplicates. Returns false if already marked as creating.

func (*ThreadCache) Set

func (tc *ThreadCache) Set(prKey string, info ThreadInfo)

Set stores thread info for a PR.

func (*ThreadCache) SetForTest

func (tc *ThreadCache) SetForTest(prKey string, info ThreadInfo)

SetForTest stores thread info with a specific UpdatedAt time (for testing only).

func (*ThreadCache) UnmarkCreating

func (tc *ThreadCache) UnmarkCreating(prKey string)

UnmarkCreating removes the creating marker for a PR.

type ThreadInfo

type ThreadInfo = state.ThreadInfo

ThreadInfo is an alias to state.ThreadInfo to avoid duplication.

Jump to

Keyboard shortcuts

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