Expand description
Support for garbage collecting unused files from downloaded files or artifacts from the target directory.
The Gc
type provides the high-level interface for the
garbage-collection system.
Garbage collection can be done “automatically” by cargo, which it does by
default once a day when running any command that does a lot of work (like
cargo build
). The entry point for this is the auto_gc
function,
which handles some basic setup, creating the Gc
, and calling
Gc::auto
.
Garbage collection can also be done manually via the cargo clean
command
by passing any option that requests deleting unused files. That is
implemented by calling the Gc::gc
method.
Garbage collection for the global cache is guided by the last-use tracking
implemented in the crate::core::global_cache_tracker
module. See that
module documentation for an in-depth explanation of how global cache
tracking works.
Structs§
- Auto
Config 🔒 - Automatic garbage collection settings from the
gc.auto
config table. - Gc
- Garbage collector.
- GcOpts
- Options to use for garbage collection.
Constants§
- DEFAULT_
AUTO_ 🔒FREQUENCY - How often auto-gc will run by default unless overridden in the config.
- DEFAULT_
MAX_ 🔒AGE_ DOWNLOADED - Default max ago to auto-clean cache data, which must be downloaded to recover.
- DEFAULT_
MAX_ 🔒AGE_ EXTRACTED - Default max age to auto-clean extracted sources, which can be recovered without downloading anything.
Functions§
- auto_gc
- Performs automatic garbage collection.
- auto_
gc_ 🔒inner - maybe_
newer_ 🔒span - Returns whichever
Duration
is shorter. - maybe_
parse_ 🔒time_ span - Parses a time span string.
- newer_
time_ 🔒span_ for_ config - Returns the shorter duration from
cur_span
versusconfig_span
. - parse_
frequency 🔒 - Parses a frequency string.
- parse_
human_ size - Parses a file size using metric or IEC units.
- parse_
time_ span - Parses a time span string.
- parse_
time_ 🔒span_ for_ config - Parses a time span value fetched from config.