@artursudnik/turborepo-purge-cache
v1.1.1
Published
A CLI tool to purge .turbo folder content based on Time-To-Live (TTL) and task cached output references
Maintainers
Readme
@artursudnik/turborepo-purge-cache
A CLI tool to purge .turbo folder content based on Time-To-Live (TTL) and task cached output references.
Turborepo's local cache can grow significantly over time. While Turborepo manages the cache, it doesn't always aggressively clean up old runs or unreferenced cache entries. This tool helps keep your .turbo folder lean.
Features
- Remove old runs: Deletes JSON files in
.turbo/runsolder than a specified number of days. - Cleanup unreferenced cache: Identifies and removes cache entries in
.turbo/cachethat are no longer referenced by any existing run files and are older than a specified TTL.
Installation
You can run it directly using npx:
npx @artursudnik/turborepo-purge-cache [path] [options]Or install it globally:
pnpm add -g @artursudnik/turborepo-purge-cacheUsage
It is recommended to use the Run Summaries
option to keep track of cache usage. Use --summarize flag to enable it or set TURBO_RUN_SUMMARY=true environment variable.
turbo-purge-cache [path] [options]Arguments
path: Path to the.turbofolder. Defaults to.turboin the current directory.
Options
--runs-ttl <days>: Number of days to keep run history files. (Default:7)--cache-ttl <days>: Number of days to keep unreferenced cached tasks. (Default:7)-h, --help: Display help for command.
Example
To keep only the last 3 days of runs and immediately remove any unreferenced cache entries:
npx @artursudnik/turborepo-purge-cache --runs-ttl 3 --cache-ttl 0How it works
- Runs Cleanup: It first scans the
.turbo/runsdirectory and deletes any.jsonfiles older than--runs-ttl. - Reference Collection: It then reads all remaining run files to collect all referenced cache hashes.
- Cache Cleanup: Finally, it scans the
.turbodirectory (where cache entries are stored as<hash>.tar.zstor similar, depending on turbo version, but usually it looks for directories/files that match the hash pattern) and removes those that:- Are NOT in the list of referenced hashes.
- ARE older than
--cache-ttl.
License
ISC
