Include more maintenance tasks
- Asset tasks - Records on this day email
This commit is contained in:
@@ -27,8 +27,10 @@ defmodule MusicLibrary.Assets.Cache do
|
||||
)
|
||||
end
|
||||
|
||||
@one_week_seconds 60 * 60 * 24 * 7
|
||||
|
||||
@spec prune(non_neg_integer()) :: non_neg_integer()
|
||||
def prune(older_than_seconds) do
|
||||
def prune(older_than_seconds \\ @one_week_seconds) do
|
||||
threshold =
|
||||
DateTime.utc_now()
|
||||
|> DateTime.add(older_than_seconds * -1, :second)
|
||||
|
||||
@@ -5,11 +5,9 @@ defmodule MusicLibrary.Worker.PruneAssetCache do
|
||||
|
||||
alias MusicLibrary.Assets.Cache
|
||||
|
||||
@one_week_seconds 60 * 60 * 24 * 7
|
||||
|
||||
@impl Oban.Worker
|
||||
def perform(_) do
|
||||
prune_count = Cache.prune(@one_week_seconds)
|
||||
prune_count = Cache.prune()
|
||||
|
||||
Logger.info(fn ->
|
||||
"Pruned #{prune_count} old cached assets. Cache size now #{Cache.total_content_size()} bytes."
|
||||
|
||||
Reference in New Issue
Block a user