v0.2.2-beta

Reference

Cache.

ngcompass caches analysis results between runs. Only changed files are re-analyzed, which makes subsequent runs significantly faster on large codebases.

How the cache works

ngcompass uses a two-layer cache: an in-memory LRU layer and a disk layer backed by cacache.

Results are stored per task (file × rule) and keyed on a hash of the file content. When a file hasn't changed since the last run, its cached results are replayed without re-parsing or re-running rules. A global full-run hash is also stored to detect config and rule changes.

The cache TTL is 24 hours by default. Configure it via the cache.ttl option in ngcompass.config.ts.

Commands

Show cache status and statistics:

bash
01npx ngcompass cache info

Clear the cache:

bash
01npx ngcompass cache clear

Clear a specific cache type:

bash
01npx ngcompass cache clear --type ast
02npx ngcompass cache clear --type config
03npx ngcompass cache clear --type results
04npx ngcompass cache clear --type all

Print the cache directory path:

bash
01npx ngcompass cache path

Skip the cache for a single run

bash
01npx ngcompass analyze --force

Bypasses the cache for the current run. Results are not written back to the cache.

Cache configuration

ngcompass.config.ts
01cache: {
02 enabled: true,
03 strategy: 'local', // 'memory' | 'local'
04 location: 'node_modules/.cache/ngcompass',
05 ttl: 86400000, // 24 hours in ms
06},
  • enabledboolean

    Enable or disable caching. Default: true.

  • strategy"memory" | "local"

    "local" writes to disk via cacache. "memory" keeps results in-process only (lost between runs).

  • locationstring

    Cache directory path. Default: node_modules/.cache/ngcompass.

  • ttlnumber

    Time-to-live in milliseconds. Default: 86400000 (24 hours).

Caching in CI

Cache the default cache directory between CI runs to speed up analysis. The default location is node_modules/.cache/ngcompass.

yaml
01- uses: actions/cache@v4
02 with:
03 path: node_modules/.cache/ngcompass
04 key: ngcompass-${{ hashFiles('src/**/*.ts') }}