-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Description
Implement Redis-based embedding cache to reduce provider costs and improve performance by caching computed embeddings.
Background
This enhancement complements Issues #51 (persistence) and #52 (Redis) by adding a caching layer for embeddings, reducing API calls to external providers and improving response times.
Requirements
- Implement Redis-based embedding cache
- Cache key format:
(model_id, sha256(content)) - Add cache TTL configuration
- Implement cache invalidation strategies
- Add cache hit/miss metrics
- Add cache size monitoring
- Implement cache warming strategies
Implementation Details
Files to modify:
src/contextforge_memory/cache/- New caching modulesrc/contextforge_memory/embeddings/- Add cache integrationsrc/contextforge_memory/config.py- Add cache configurationtests/- Add cache testsREADME.md- Document cache configuration
Technical approach:
- Create embedding cache service with Redis backend
- Implement cache-aside pattern for embeddings
- Add cache key generation with content hashing
- Implement cache metrics and monitoring
- Add cache configuration options
Acceptance Criteria
- Embeddings are cached correctly with proper keys
- Cache hit rate improves performance measurably
- Cache TTL and invalidation work correctly
- Cache metrics are tracked and exposed
- Configuration is flexible and documented
Testing Requirements
- Unit tests for cache operations
- Integration tests with Redis
- Performance tests for cache benefits
- Cache invalidation tests
Documentation Updates
- README.md - Document cache configuration
- Performance guide - Cache benefits
- Configuration examples - Cache setup
- Monitoring guide - Cache metrics
Related Issues
- Complements: [P0] Add pluggable vector index backend (FAISS/pgvector/Weaviate) #51 (persistence), [P0] Add persistent session store with Redis/Postgres backend and TTL #52 (Redis)
- Depends on: None
- Blocks: None