forked from cardosofelipe/fast-next-template
Add comprehensive caching layer for the Agent Memory System: - HotMemoryCache: LRU cache for frequently accessed memories - Python 3.12 type parameter syntax - Thread-safe operations with RLock - TTL-based expiration - Access count tracking for hot memory identification - Scoped invalidation by type, scope, or pattern - EmbeddingCache: Cache embeddings by content hash - Content-hash based deduplication - Optional Redis backing for persistence - LRU eviction with configurable max size - CachedEmbeddingGenerator wrapper for transparent caching - CacheManager: Unified cache management - Coordinates hot cache, embedding cache, and retrieval cache - Centralized invalidation across all caches - Aggregated statistics and hit rate tracking - Automatic cleanup scheduling - Cache warmup support Performance targets: - Cache hit rate > 80% for hot memories - Cache operations < 1ms (memory), < 5ms (Redis) 83 new tests with comprehensive coverage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
22 lines
562 B
Python
22 lines
562 B
Python
# app/services/memory/cache/__init__.py
|
|
"""
|
|
Memory Caching Layer.
|
|
|
|
Provides caching for memory operations:
|
|
- Hot Memory Cache: LRU cache for frequently accessed memories
|
|
- Embedding Cache: Cache embeddings by content hash
|
|
- Cache Manager: Unified cache management with invalidation
|
|
"""
|
|
|
|
from .cache_manager import CacheManager, CacheStats, get_cache_manager
|
|
from .embedding_cache import EmbeddingCache
|
|
from .hot_cache import HotMemoryCache
|
|
|
|
__all__ = [
|
|
"CacheManager",
|
|
"CacheStats",
|
|
"EmbeddingCache",
|
|
"HotMemoryCache",
|
|
"get_cache_manager",
|
|
]
|