Skip to content

Add Redis/SolidCache ephemeral caching layer for retrieval pipeline#18

Merged
LeahArmstrong merged 5 commits intomainfrom
claude/redis-token-caching-EpZ5N
Feb 28, 2026
Merged

Add Redis/SolidCache ephemeral caching layer for retrieval pipeline#18
LeahArmstrong merged 5 commits intomainfrom
claude/redis-token-caching-EpZ5N

Conversation

@LeahArmstrong
Copy link
Owner

Introduces a backend-agnostic cache store abstraction with three backends
(InMemory, Redis, SolidCache) that caches expensive operations across the
retrieval pipeline and MCP sessions:

  • Embedding vectors cached by text hash (eliminates redundant API calls)
  • Pre-formatted LLM context cached by query+budget (zero recomputation)
  • CachedEmbeddingProvider decorator wraps any Provider::Interface
  • CachedRetriever decorator wraps Retriever with context-level caching
  • Builder auto-wires cache when cache_enabled config is true
  • 5 namespaced TTL domains (embeddings: 24h, context: 15min, etc.)
  • 40 new specs covering all cache stores, middleware, and edge cases

https://claude.ai/code/session_01V3fpEonNoFGNTRxFWpHST6

@LeahArmstrong LeahArmstrong force-pushed the claude/redis-token-caching-EpZ5N branch from e12a4fd to 63f8a53 Compare February 28, 2026 16:55
@LeahArmstrong LeahArmstrong requested review from Copilot and removed request for Copilot February 28, 2026 17:50
LeahArmstrong pushed a commit that referenced this pull request Feb 28, 2026
- view_template_extractor_spec: move mocks into `it` block with
  `a_string_matching` regex (aligns with PR #19 approach for cleaner
  merge)
- CacheStore#fetch: expand YARD @note documenting nil-as-cache-miss
  semantic so custom backend implementers preserve the contract
- SolidCacheStore#clear: log a warning when the backend lacks
  delete_matched instead of silently no-oping

https://claude.ai/code/session_01V3fpEonNoFGNTRxFWpHST6
claude and others added 5 commits February 28, 2026 14:58
Introduces a backend-agnostic cache store abstraction with three backends
(InMemory, Redis, SolidCache) that caches expensive operations across the
retrieval pipeline and MCP sessions:

- Embedding vectors cached by text hash (eliminates redundant API calls)
- Pre-formatted LLM context cached by query+budget (zero recomputation)
- CachedEmbeddingProvider decorator wraps any Provider::Interface
- CachedRetriever decorator wraps Retriever with context-level caching
- Builder auto-wires cache when cache_enabled config is true
- 5 namespaced TTL domains (embeddings: 24h, context: 15min, etc.)
- 40 new specs covering all cache stores, middleware, and edge cases

https://claude.ai/code/session_01V3fpEonNoFGNTRxFWpHST6
- Remove dead structural_ttl param from CachedRetriever (accepted but
  never read — structural context is already cached as part of the full
  RetrievalResult, making a separate TTL unnecessary)
- Add NOTE on CacheStore#fetch explaining nil-as-miss behavior

https://claude.ai/code/session_01V3fpEonNoFGNTRxFWpHST6
- Extract partition_cached helper in CachedEmbeddingProvider to fix
  Metrics/MethodLength on embed_batch (22→13 lines)
- Convert guard clause in SolidCacheCacheStore#clear
- Remove redundant map(&:to_s) before join in cache_key
- Fix line length in view_template_extractor_spec
- Fix semicolon in cache_store_spec fetch block
- Add Metrics/ClassLength disable to Builder (107/100 after cache methods)
- Preserve block form for custom fetch (not Hash#fetch) with inline cop disable

https://claude.ai/code/session_01V3fpEonNoFGNTRxFWpHST6
- view_template_extractor_spec: move mocks into `it` block with
  `a_string_matching` regex (aligns with PR #19 approach for cleaner
  merge)
- CacheStore#fetch: expand YARD @note documenting nil-as-cache-miss
  semantic so custom backend implementers preserve the contract
- SolidCacheStore#clear: log a warning when the backend lacks
  delete_matched instead of silently no-oping

https://claude.ai/code/session_01V3fpEonNoFGNTRxFWpHST6
- Rename SolidCacheCacheStore to SolidCacheStore (stuttering name)
- Raise ArgumentError on unknown cache_store config (matches other builders)
- Add connection error resilience to Redis and SolidCache stores
  (read/exist? degrade to miss, write/delete log and return nil)
- Handle corrupted JSON: delete bad key and return nil
- Wrap cache writes in fetch/middleware with rescue so computed
  values are always returned even when cache backend is down
- Add RedisCacheStore and SolidCacheStore specs with mock doubles
@LeahArmstrong LeahArmstrong force-pushed the claude/redis-token-caching-EpZ5N branch from 12485cd to 8f05e47 Compare February 28, 2026 20:05
@LeahArmstrong LeahArmstrong merged commit c058646 into main Feb 28, 2026
5 checks passed
@LeahArmstrong LeahArmstrong deleted the claude/redis-token-caching-EpZ5N branch February 28, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants