[turbopack] Retain fewer stale cache versions and use a TTL (#96941)
In CI we do not retain old versions of the db at all, but in dev or non-CI settings we would retain up to 2 indefinitely. Given how large caches can grow, this PR reduces it to no more than 1 old version, and then only for a certain amount of time, currently 3 days. The idea being to support switching back and forth between feature branches and a next.js upgrade branch, 3 days allows this worflow to survive a weekend. To support this the `CURRENT` file format is modified. Instead of just storing a sequence number it now stores a small json object containing the `max_sequence_number` and the mtime. We store the last_write_time in the file to support the fact that we anticipate `cache` directories to be copied around and the native mtime would record the copy time instead of the commit time. This should reduce dev time disk usage in the common case.
Showing
This diff is collapsed.
Please
register
or
sign in
to comment