Electric.AsyncDeleter (electric v1.2.4)

View Source

A GenServer that batches file/directory deletions by first moving them into a per-stack trash directory and then, after a configurable interval, removing the trash directory contents in one rm -rf operation.

This reduces filesystem churn when many deletes happen in quick succession (e.g. cache eviction) and avoids blocking callers: delete/1 returns after a quick File.rename/2 into the trash directory.

Configuration:

  • :cleanup_interval_ms - interval in milliseconds after the first queued delete before the batch is removed. Defaults to 10000 ms.

Summary

Functions

Returns a specification to start this module under a supervisor.

Deletes a file or directory using rm -rf. Returns {:ok, output} on success or {:error, reason} on failure.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clean_dir!(path)

delete(path, opts)

Deletes a file or directory using rm -rf. Returns {:ok, output} on success or {:error, reason} on failure.

name(stack_id)

start_link(opts)

trash_dir(storage_dir, stack_id)

trash_dir!(stack_id)