Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

  1. On scan start, loads the cache from .ghostdep-cache/scan.json
  2. For each source file, computes a blake3 hash of the content
  3. If the hash matches the cached entry, reuses the cached imports (skips AST parsing)
  4. If the hash differs or the file is new, parses it and updates the cache
  5. After the scan, writes the updated cache to disk
  6. 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).