Prune asset cache every 12 hours

This commit is contained in:
Claudio Ortolina
2025-09-20 08:17:16 +03:00
parent 772de1751e
commit a1b5842148
3 changed files with 40 additions and 1 deletions
@@ -0,0 +1,18 @@
defmodule MusicLibrary.Worker.PruneAssetCache do
use Oban.Worker, queue: :default, max_attempts: 3
require Logger
alias MusicLibrary.Assets.Cache
@one_week_seconds 60 * 60 * 24 * 7
@impl Oban.Worker
def perform(_) do
prune_count = Cache.prune(@one_week_seconds)
Logger.info(fn ->
"Pruned #{prune_count} old cached assets. Cache size now #{Cache.total_content_size()} bytes."
end)
end
end