Sweeps, every :every seconds, on a store with no lifecycle rule (the
local disk, MinIO):
- the temporary files of forms never saved: those under the temporary
prefix (
Storehouse.cache_prefix/0) older than:max_age; - the files that expired (
Storehouse.expiring_key/2), once their time has come; - the multipart uploads started more than
:max_ageago and never completed (Storehouse.presign_multipart/4), whose parts the store keeps (and bills) until they are given up.
On several nodes, each sweep runs on one of them at a time.
# lib/my_app/application.ex
children = [
MyApp.Repo,
{Storehouse.Sweeper, max_age: 86_400},
MyAppWeb.Endpoint
]A bucket with lifecycle rules for the prefixes needs none. sweep/1
does the same once, for a scheduled job of the app's.
Options
:max_age- in seconds. The default is a day.:every- in seconds. The default is an hour.:prefix- the default isStorehouse.cache_prefix/0.:expiring- whether expired files are swept. The default istrue.:multipart- whether abandoned multipart uploads are given up, where the store lists them. The default istrue.:adapter- the store. The default isStorehouse.adapter/0.
Summary
Functions
Starts the sweeper, registered as Storehouse.Sweeper.
Deletes, at once, the files under the temporary prefix that are older
than :max_age seconds, and the files that expired. Gives
{:ok, count}.
Functions
@spec start_link(keyword()) :: GenServer.on_start()
Starts the sweeper, registered as Storehouse.Sweeper.
@spec sweep(keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Deletes, at once, the files under the temporary prefix that are older
than :max_age seconds, and the files that expired. Gives
{:ok, count}.
Takes :max_age (the default is a day), :prefix (the default is
Storehouse.cache_prefix/0), :expiring and :multipart (the defaults
are true) and :adapter. The count is of files and uploads.