Documentation
¶
Index ¶
- Variables
- type Cache
- func (c *Cache) AddToDownloaded(item gofeed.Item)
- func (c *Cache) GetArticles(feed *rss.Feed, ignoreCache bool) (SortableArticles, error)
- func (c *Cache) GetArticlesBulk(feeds []*rss.Feed, ignoreCache bool) SortableArticles
- func (c *Cache) GetDownloaded() SortableArticles
- func (c *Cache) Load() error
- func (c *Cache) RemoveFromDownloaded(index int) error
- func (c *Cache) Save() error
- type Entry
- type ReadStatus
- type SortableArticles
Constants ¶
This section is empty.
Variables ¶
var DefaultCacheDuration = 24 * time.Hour
DefaultCacheDuration is the default duration for which an item is cached
var DefaultCacheSize = 100
DefaultCacheSize is the default size of the cache
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { Content map[string]Entry `json:"content"` Downloaded SortableArticles `json:"downloaded"` OfflineMode bool `json:"-"` // contains filtered or unexported fields }
Cache handles the caching of feeds and storing downloaded articles
func (*Cache) AddToDownloaded ¶
AddToDownloaded adds an item to the downloaded list
func (*Cache) GetArticles ¶
GetArticles returns an article list using the cache if possible
func (*Cache) GetArticlesBulk ¶
func (c *Cache) GetArticlesBulk(feeds []*rss.Feed, ignoreCache bool) SortableArticles
GetArticlesBulk returns a sorted list of articles from all the given urls, ignoring any errors
func (*Cache) GetDownloaded ¶
func (c *Cache) GetDownloaded() SortableArticles
GetDownloaded returns a list of downloaded items
func (*Cache) RemoveFromDownloaded ¶
RemoveFromDownloaded removes an item from the downloaded list
type Entry ¶
type Entry struct { Expire time.Time `json:"expire"` Articles SortableArticles `json:"articles"` }
Entry is a cache entry
type ReadStatus ¶
type ReadStatus struct {
// contains filtered or unexported fields
}
ReadStatus is a set containing the hashes of the already read articles. We use a struct{} here because it takes up no space in memory. To hash the article, we use the URL of the feed and the title of the article.
func NewReadStatus ¶
func NewReadStatus(dir string) (*ReadStatus, error)
New creates a new ReadStatus set.
func (ReadStatus) IsRead ¶
func (rs ReadStatus) IsRead(url string) bool
IsRead checks if an article is already in the set.
func (*ReadStatus) MarkAsRead ¶
func (rs *ReadStatus) MarkAsRead(url string)
MarkAsRead adds an article to the set.
func (*ReadStatus) MarkAsUnread ¶
func (rs *ReadStatus) MarkAsUnread(url string)
MarkAsUnread removes an article from the set.
type SortableArticles ¶
SortableArticles is a sortable list of articles
func (SortableArticles) Len ¶
func (sa SortableArticles) Len() int
Len returns the length of the item list, needed for sorting
func (SortableArticles) Less ¶
func (sa SortableArticles) Less(a, b int) bool
Less returns true if the item at index i is less than the item at index j, needed for sorting
func (SortableArticles) Swap ¶
func (sa SortableArticles) Swap(a, b int)
Swap swaps the items at index i and j, needed for sorting