Documentation
¶
Index ¶
- Constants
- func GetDefaultCacheDir() (string, error)
- type Cache
- func (c *Cache) AddNotifications(notifications []CacheEntry) []CacheEntry
- func (c *Cache) AddStarEvents(starEvents []StarEvent) []StarEvent
- func (c *Cache) Clear()
- func (c *Cache) GetNotifications() []CacheEntry
- func (c *Cache) GetStars() []StarEvent
- func (c *Cache) Load(cacheDir string) error
- func (c *Cache) Save(cacheDir string) error
- type CacheEntry
- type StarEvent
Constants ¶
View Source
const ( DefaultMaxEntries = 500 MaxAge = 30 * 24 * time.Hour // 30 days CacheVersion = "1.0" )
Variables ¶
This section is empty.
Functions ¶
func GetDefaultCacheDir ¶
Types ¶
type Cache ¶
type Cache struct {
Version string `json:"version"`
LastSync time.Time `json:"last_sync"`
Notifications []CacheEntry `json:"notifications"`
Stars []StarEvent `json:"stars"`
LastEventSync time.Time `json:"last_event_sync"` // Track last sync for rate limiting
MaxEntries int `json:"max_entries"`
}
Cache stores notifications and star events with their metadata.
IMPORTANT: All time.Time fields should use UTC to match GitHub API responses and ensure consistent time comparisons across different timezones. Use time.Now().UTC() when setting time fields to maintain consistency.
func (*Cache) AddNotifications ¶
func (c *Cache) AddNotifications(notifications []CacheEntry) []CacheEntry
func (*Cache) AddStarEvents ¶ added in v1.1.0
AddStarEvents adds star events to the cache and returns only new ones
func (*Cache) GetNotifications ¶
func (c *Cache) GetNotifications() []CacheEntry
type CacheEntry ¶
type CacheEntry struct {
ID string `json:"id"`
Repository string `json:"repository"`
Title string `json:"title"`
Reason string `json:"reason"`
Type string `json:"type"`
URL string `json:"url"`
WebURL string `json:"web_url"`
Timestamp time.Time `json:"timestamp"`
UpdatedAt time.Time `json:"updated_at"`
}
type StarEvent ¶ added in v1.1.0
type StarEvent struct {
ID string `json:"id"`
Repository string `json:"repository"` // Full name: "owner/repo"
StarredBy string `json:"starred_by"`
StarredAt time.Time `json:"starred_at"`
Notified bool `json:"notified"`
}
StarEvent represents a star event for caching
Click to show internal directories.
Click to hide internal directories.