package cache import ( "sync" "time" ) // FeedItem represents a cached feed item type FeedItem struct { EventID string Author string Content string Time time.Time Link string Title string Summary string Image string } // FeedCache stores the kind 1 feed type FeedCache struct { items []FeedItem mu sync.RWMutex lastUpdated time.Time } // NewFeedCache creates a new feed cache func NewFeedCache() *FeedCache { return &FeedCache{ items: make([]FeedItem, 0), } } // Set updates the feed cache func (fc *FeedCache) Set(items []FeedItem) { fc.mu.Lock() defer fc.mu.Unlock() fc.items = items fc.lastUpdated = time.Now() } // Get retrieves feed items func (fc *FeedCache) Get() []FeedItem { fc.mu.RLock() defer fc.mu.RUnlock() return fc.items } // GetLastUpdated returns when the feed was last updated func (fc *FeedCache) GetLastUpdated() time.Time { fc.mu.RLock() defer fc.mu.RUnlock() return fc.lastUpdated }