Caching
Mutagoph caches mutation results to skip unchanged mutations on subsequent runs.
How It Works
The cache stores results based on:
- Mutation ID
- Source file content hash
- Test file content hashes
If none of these change, the cached result is used.
Usage
# Enable caching (default)
mutagoph run --cache
# Disable caching
mutagoph run --cache=false
# Specify cache directory
mutagoph run --cache-dir /tmp/mutagoph-cache
# Clear cache before running
mutagoph run --clear-cache
Cache Location
Default: ~/.cache/mutagoph
The cache directory contains:
- Memory cache (in-process, for repeated mutations)
- Disk cache (persistent, survives restarts)
Cache Statistics
When caching is enabled, statistics are shown:
Cache: 142 entries (1.2 MB)
When to Clear Cache
Clear the cache when:
- Test logic changes but test files don’t
- Build configuration changes
- Dependency versions change
- Experiencing unexpected results
mutagoph run --clear-cache
CI Caching
For CI, cache the mutagoph cache directory between runs:
# GitHub Actions
- name: Cache mutagoph results
uses: actions/cache@v4
with:
path: ~/.cache/mutagoph
key: mutagoph-$-$
restore-keys: |
mutagoph-$-
Performance Impact
Caching can provide significant speedups:
- First run: Full execution
- Subsequent runs: Only changed mutations tested
- Typical speedup: 10-100x for incremental changes