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

6. Cache strategy for collectors

Date: 2026-04-22

Status

Accepted

Context

Collectors (git, opencode, todos) can be expensive. Avoid re-running them on every build.

Decision

Cerebro uses file-based caching:

  • Cache stored in cache.json in system cache directory
  • Each entry tracks: opencode_last_query, git_last_scan, todo_last_scan
  • --fresh flag bypasses cache entirely
  • --project <name> limits to specific project

Cache Invalidation

Cerebro invalidates the cache when:

  1. --fresh flag for user override
  2. Timestamps in cache.json show data is stale
  3. Manual cerebro status shows cache status

Consequences

Pros

  • Fast subsequent builds
  • Respects user intent

Cons

  • Stale data if TTL too long
  • System cache dependency

Notes

See cache.rs for implementation.