Documentation
¶
Overview ¶
Package cache provides thread information caching for bot operations.
Index ¶
- type CommitPRCache
- type CommitPREntry
- type ThreadCache
- func (tc *ThreadCache) Cleanup(maxAge time.Duration)
- func (tc *ThreadCache) Get(prKey string) (ThreadInfo, bool)
- func (tc *ThreadCache) IsCreating(prKey string) bool
- func (tc *ThreadCache) MarkCreating(prKey string) bool
- func (tc *ThreadCache) Set(prKey string, info ThreadInfo)
- func (tc *ThreadCache) SetForTest(prKey string, info ThreadInfo)
- func (tc *ThreadCache) UnmarkCreating(prKey string)
- type ThreadInfo
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.
type CommitPREntry ¶
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 (*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.