aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/cache/v1.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/feed/cache/v1.go')
-rw-r--r--internal/feed/cache/v1.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/feed/cache/v1.go b/internal/feed/cache/v1.go
index 0363303..5675db5 100644
--- a/internal/feed/cache/v1.go
+++ b/internal/feed/cache/v1.go
@@ -23,6 +23,7 @@ const (
v1Version Version = 1
startFeedId uint64 = 1
maxCacheSize = 1000
+ maxCacheDays = 180
)
type feedId uint64
@@ -376,6 +377,21 @@ func filterItems(items []cachedItem) []cachedItem {
return copiedItems
}
+func (cache *v1Cache) cleanup(knownDescriptors map[feed.Descriptor]bool) {
+ for descr, id := range cache.Ids {
+ if knownDescriptors[descr] {
+ // do not delete stuff still known to us
+ continue
+ }
+
+ cf := cache.Feeds[id]
+ if cf.LastCheck.IsZero() || util.Days(time.Since(cf.LastCheck)) > maxCacheDays {
+ delete(cache.Feeds, id)
+ delete(cache.Ids, descr)
+ }
+ }
+}
+
func (cache *v1Cache) load(reader io.Reader) error {
decoder := gob.NewDecoder(reader)
return decoder.Decode(cache)