add expiry to cached full size cover art

This commit is contained in:
Drew Weymouth
2023-07-18 18:31:20 -07:00
parent 69fa726894
commit 1465479f2a
2 changed files with 27 additions and 3 deletions
+9
View File
@@ -29,6 +29,12 @@ type ImageCache struct {
MaxSize int
DefaultTTL time.Duration
// Sets a callback that is invoked whenever the periodic
// eviction has been run. Allows for "tacking on" extra
// cleanup tasks outside of the ImageCache's jurisdiction
// that are run on the same schedule.
OnEvictTaskRan func()
mu sync.RWMutex
cache map[string]CacheItem
}
@@ -157,6 +163,9 @@ func (i *ImageCache) periodicallyEvict(ctx context.Context, interval time.Durati
return
case <-t.C:
i.EvictExpired()
if i.OnEvictTaskRan != nil {
i.OnEvictTaskRan()
}
}
}
}