feat: add output cache system with TTL and diff detection#554
Open
bz00qa wants to merge 2 commits intortk-ai:developfrom
Open
feat: add output cache system with TTL and diff detection#554bz00qa wants to merge 2 commits intortk-ai:developfrom
bz00qa 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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