cache

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cache = &cacheProxy{}

Cache is now a proxy to the manager's cache

Functions

func AsyncRefreshCache added in v1.5.3

func AsyncRefreshCache(dirs []string, author string, cacheFilePath string, excludedPatterns []string, excludedPaths []string)

AsyncRefreshCache performs a non-blocking cache refresh

func CleanCache added in v1.5.2

func CleanCache(cacheFilePath string) error

CleanCache removes the cache file and resets the in-memory cache

func InitCache

func InitCache()

InitCache - Initializes the cache manager

func LoadCache

func LoadCache(filePath string) error

LoadCache - loads repository metadata from cache file

func QuickNeedsRefresh added in v1.5.3

func QuickNeedsRefresh(refreshInterval time.Duration) bool

QuickNeedsRefresh performs a fast check if refresh is needed

func RefreshCache

func RefreshCache(dirs []string, author string, cacheFilePath string, excludedPatterns []string, excludedPaths []string) error

RefreshCache - updates the cache with fresh data

func SaveCache

func SaveCache(filePath string) error

SaveCache - saves the cache to disk

Types

type AuthorStats added in v1.6.3

type AuthorStats struct {
	TotalCommits  int
	ActiveDays    map[string]bool
	CurrentStreak int
	LongestStreak int
	Languages     map[string]int
	PeakHours     map[int]int
	LastActivity  time.Time
}

AuthorStats holds aggregated statistics for an author

type CacheManager added in v1.6.3

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

CacheManager handles all cache operations

func NewCacheManager added in v1.6.3

func NewCacheManager(cachePath string) *CacheManager

NewCacheManager creates a new cache manager instance

func (*CacheManager) GetCommits added in v1.6.3

func (cm *CacheManager) GetCommits(options QueryOptions) []scan.CommitHistory

GetCommits retrieves commits based on query options

func (*CacheManager) Load added in v1.6.3

func (cm *CacheManager) Load() error

Load reads the cache from disk

func (*CacheManager) Refresh added in v1.6.3

func (cm *CacheManager) Refresh() error

Refresh updates the cache with fresh data

func (*CacheManager) RefreshInBackground added in v1.6.3

func (cm *CacheManager) RefreshInBackground()

RefreshInBackground performs a non-blocking cache refresh

func (*CacheManager) Save added in v1.6.3

func (cm *CacheManager) Save() error

Save persists the cache to disk

func (*CacheManager) StartBackgroundRefresh added in v1.6.3

func (cm *CacheManager) StartBackgroundRefresh(interval time.Duration)

StartBackgroundRefresh initiates background refresh with specified interval

type CacheUpdate added in v1.6.3

type CacheUpdate struct {
	Type    string
	RepoID  string
	Changes int
}

CacheUpdate represents a cache update notification

type CommitCache added in v1.6.3

type CommitCache struct {
	// Core data
	Commits  map[string][]scan.CommitHistory // repo -> commits
	Authors  map[string]AuthorStats          // author -> stats
	LastSync time.Time
	Version  string

	// Performance optimizations
	CommitIndex map[string]map[string]bool // hash -> repo -> exists
	DateIndex   map[string][]string        // YYYY-MM-DD -> commit hashes
	AuthorIndex map[string][]string        // author -> commit hashes

	// Pre-calculated display data
	DisplayStats DisplayStats

	// Metadata
	Repositories map[string]scan.RepoMetadata
}

CommitCache represents the optimized cache structure

type DisplayStats added in v1.6.3

type DisplayStats struct {
	WeeklyTotal    int
	WeeklyDiff     int
	DailyAverage   float64
	TotalAdditions int
	TotalDeletions int
	PeakHour       int
	PeakCommits    int
	LanguageStats  map[string]int
	RepoStats      []RepoDisplayStats
	LastUpdate     time.Time
}

DisplayStats holds pre-calculated statistics for display

type QueryOptions added in v1.6.3

type QueryOptions struct {
	Author     string
	Repository string
	Since      time.Time
	Until      time.Time
}

QueryOptions defines parameters for commit queries

type RepoDisplayStats added in v1.6.3

type RepoDisplayStats struct {
	Name           string
	WeeklyCommits  int
	CurrentStreak  int
	LongestStreak  int
	Additions      int
	Deletions      int
	LastCommitTime time.Time
}

RepoDisplayStats holds pre-calculated statistics for a repository

Jump to

Keyboard shortcuts

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