feat: add output cache system with TTL and diff detection#554
feat: add output cache system with TTL and diff detection#554bz00qa wants to merge 2 commits intortk-ai:developfrom
Conversation
New cache module for caching filtered command output: - File-based cache in ~/.local/share/rtk/cache/ with deterministic keys (command + cwd hash) - Configurable TTL (default 5min) via config.toml or RTK_CACHE_TTL env var - Enable/disable via config.toml or RTK_CACHE env var - Volatile command detection (git status, ls, etc. are never cached) - Line-level diff between cached and current output with truncation - `rtk cache-clear` command to reset cache Tracking integration: - New cache_hit column in SQLite tracking database - record_cache_hit() and track_cache_hit() methods - All gain/analytics queries exclude cache hits (AND cache_hit = 0) to keep savings stats accurate - get_cache_stats() for cache performance reporting Config: - CacheConfig struct in config.toml ([cache] section) - enabled (default: true), ttl_minutes (default: 5) 11 tests for cache module, all existing tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: bz00qa <bz00qa.hub@gmail.com>
373d384 to
7cf47d0
Compare
Signed-off-by: bZ00qa <167500396+bz00qa@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
This PR has merge conflicts with git fetch upstream develop
git rebase upstream/develop
git push --force-with-leaseLabeling |
|
|
|
Hey We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes No logic changes — only file moves and import path updates. What you need to doRebase your branch on git fetch origin && git rebase origin/developGit detects renames automatically. If you get import conflicts, update the paths: use crate::git; // now: use crate::cmds::git::git;
use crate::tracking; // now: use crate::core::tracking;
use crate::config; // now: use crate::core::config;
use crate::init; // now: use crate::hooks::init;
use crate::gain; // now: use crate::analytics::gain;Need help rebasing? Tag @aeppling |
Summary
cache.rs: File-based output cache with deterministic keys (command + cwd hash), configurable TTL, volatile command detection, and line-level diff between cached/current outputrtk cache-clear: CLI command to reset the cachecache_hitcolumn in SQLite — all gain/analytics queries exclude cache hits to keep savings stats accurate[cache]section inconfig.tomlwithenabled(default: true) andttl_minutes(default: 5), overridable viaRTK_CACHEandRTK_CACHE_TTLenv varsHow it works
When
proxy -f(from #553) or future commands use the cache:Volatile commands (
git status,ls,find, etc.) are never cached.Tests
11 new tests covering key generation, volatile detection, diff computation, and truncation.
Test plan
cargo fmt --allpassescargo clippy --all-targetspasses (no new warnings)cargo test— 898 passed, 11 new cache tests all greenrtk cache-clearclears cache directory[cache]section appears inrtk config🤖 Generated with Claude Code