Storehouse.Sweeper (Storehouse v0.2.0)

Copy Markdown View Source

Sweeps, every :every seconds, on a store with no lifecycle rule (the local disk, MinIO):

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 is Storehouse.cache_prefix/0.
  • :expiring - whether expired files are swept. The default is true.
  • :multipart - whether abandoned multipart uploads are given up, where the store lists them. The default is true.
  • :adapter - the store. The default is Storehouse.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

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the sweeper, registered as Storehouse.Sweeper.

sweep(opts \\ [])

@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.