Module gc

Source
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Β§

Gc
Garbage collector.
GcOpts
Options to use for garbage collection.
GlobalCleanConfig πŸ”’
Cache cleaning settings from the cache.global-clean config table.

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 versus config_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.