Caching
ghostdep supports incremental scanning — it caches parsed imports so unchanged files don’t need to be re-parsed.
Enable caching
ghostdep --cache
Or in .ghostdep.yaml:
cache: true
How it works
- On scan start, loads the cache from
.ghostdep-cache/scan.json - For each source file, computes a blake3 hash of the content
- If the hash matches the cached entry, reuses the cached imports (skips AST parsing)
- If the hash differs or the file is new, parses it and updates the cache
- After the scan, writes the updated cache to disk
- Entries for deleted files are pruned automatically
Cache location
.ghostdep-cache/
└── scan.json
In your project root. Add .ghostdep-cache/ to your .gitignore.
Cache invalidation
The cache includes a version number. When ghostdep’s import extraction logic changes between releases, the cache is automatically invalidated and rebuilt.
CI usage
Cache the .ghostdep-cache/ directory between CI runs for faster repeat scans:
# GitHub Actions
- uses: actions/cache@v4
with:
path: .ghostdep-cache
key: ghostdep-${{ hashFiles('**/*.rs', '**/*.py', '**/*.js', '**/*.go', '**/*.java') }}
restore-keys: ghostdep-
- name: Scan
run: ghostdep --cache
Thread safety
The cache uses RwLock internally, so it’s safe to use with parallel scanning (--threads).