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.jsonin the system cache directory - Each entry tracks:
opencode_last_query,git_last_scan,todo_last_scan - The
--freshflag bypasses the cache entirely - The
--project <name>flag limits the build to a specific project
Cache invalidation
Cerebro invalidates the cache when:
- The user passes
--freshto override it - Timestamps in
cache.jsonshow the data is stale
cerebro status reports cache state for manual checks.
Consequences
Pros
- Subsequent builds are fast
- The
--freshflag 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.