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

The git, OpenCode, and TODO collectors can be expensive. Avoid re-running them on every build.

Decision

Cerebro uses file-based caching:

  • The cache lives in cache.json in the system cache directory
  • Each entry tracks: opencode_last_query, git_last_scan, todo_last_scan
  • The --fresh flag bypasses the cache entirely
  • The --project <name> flag limits the build to a specific project

Cache invalidation

Cerebro invalidates the cache when:

  1. The user passes --fresh to override it
  2. Timestamps in cache.json show the data is stale

cerebro status reports cache state for manual checks.

Consequences

Pros

  • Subsequent builds are fast
  • The --fresh flag respects explicit user intent

Cons

  • Data goes stale if the TTL is too long
  • Relies on the system cache directory

Notes

See cache.rs for the implementation.