Skip to content

Commit

Permalink
Document disk cache garbage collection.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 680521067
Change-Id: I6c018eeaf73d8c7d8763774dad609c450faa87ac
  • Loading branch information
tjgq authored and copybara-github committed Sep 30, 2024
1 parent 6922734 commit 544e235
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions site/en/remote/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,8 @@ This feature is unsupported on Windows.

Bazel can use a directory on the file system as a remote cache. This is
useful for sharing build artifacts when switching branches and/or working
on multiple workspaces of the same project, such as multiple checkouts. Since
Bazel does not garbage-collect the directory, you might want to automate a
periodic cleanup of this directory. Enable the disk cache as follows:
on multiple workspaces of the same project, such as multiple checkouts.
Enable the disk cache as follows:

```posix-terminal
build --disk_cache={{ '<var>' }}path/to/build/cache{{ '</var>' }}
Expand All @@ -305,6 +304,18 @@ You can pass a user-specific path to the `--disk_cache` flag using the `~` alias
when enabling the disk cache for all developers of a project via the project's
checked in `.bazelrc` file.

### Garbage collection {:#disk-cache-gc}

Starting with Bazel 7.4, you can use `--experimental_disk_cache_gc_max_size` and
`--experimental_disk_cache_gc_max_age` to set a maximum size for the disk cache
or for the age of individual cache entries. Bazel will automatically garbage
collect the disk cache while idling between builds; the idle timer can be set
with `--experimental_disk_cache_gc_idle_delay` (defaulting to 5 minutes).

As an alternative to automatic garbage collection, we also provide a [tool](
https://github.com/bazelbuild/bazel/tree/master/src/tools/diskcache) to run a
garbage collection on demand.

## Known issues {:#known-issues}

**Input file modification during a build**
Expand Down

0 comments on commit 544e235

Please sign in to comment.