feat(context): implement Redis-based caching layer (#84)

Phase 6 of Context Management Engine - Caching Layer:

- Add ContextCache with Redis integration
- Support fingerprint-based assembled context caching
- Support token count caching (model-specific)
- Support score caching (scorer + context + query)
- Add in-memory fallback with LRU eviction
- Add cache invalidation with pattern matching
- Add cache statistics reporting

Key features:
- Hierarchical cache key structure (ctx:type:hash)
- Automatic TTL expiration
- Memory cache for fast repeated access
- Graceful degradation when Redis unavailable

Tests: 29 new tests, 285 total context tests passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-04 02:41:21 +01:00
parent 7828d35e06
commit c2466ab401
4 changed files with 907 additions and 0 deletions

View File

@@ -3,3 +3,9 @@ Context Cache Module.
Provides Redis-based caching for assembled contexts.
"""
from .context_cache import ContextCache
__all__ = [
"ContextCache",
]