Spaces:
Running
on
Zero
Running
on
Zero
| """Caching module for Portfolio Intelligence Platform. | |
| This module provides production-ready caching infrastructure with: | |
| - Hybrid caching (Redis primary, in-memory fallback) | |
| - Domain-specific TTL strategies for financial data | |
| - Event-driven cache invalidation | |
| - Cache warming capabilities | |
| - Comprehensive monitoring and statistics | |
| Example: | |
| Basic usage with HybridCache: | |
| >>> from backend.caching import HybridCache, FinancialDataCacheManager | |
| >>> from backend.config import settings | |
| >>> | |
| >>> cache = HybridCache( | |
| ... redis_url=settings.upstash_redis_url, | |
| ... redis_token=settings.upstash_redis_token, | |
| ... ) | |
| >>> manager = FinancialDataCacheManager(cache) | |
| >>> | |
| >>> # Cache market data | |
| >>> manager.cache_market_data("AAPL", {"price": 150.00, "volume": 1000000}) | |
| >>> | |
| >>> # Retrieve cached data | |
| >>> data = manager.get_market_data("AAPL") | |
| >>> | |
| >>> # Get statistics | |
| >>> stats = manager.get_stats() | |
| >>> print(f"Hit rate: {stats.hit_rate:.2f}%") | |
| """ | |
| from backend.caching.decorators import ( | |
| cached, | |
| cached_async, | |
| cache_invalidate, | |
| ) | |
| from backend.caching.factory import ( | |
| CacheFactory, | |
| get_cache, | |
| get_cache_manager, | |
| cache, | |
| cache_manager, | |
| ) | |
| from backend.caching.redis_cache import ( | |
| CacheBackend, | |
| CacheDataType, | |
| CacheInvalidationManager, | |
| CacheKey, | |
| CacheStats, | |
| FinancialDataCacheManager, | |
| HybridCache, | |
| InMemoryCache, | |
| PortfolioCachingStrategy, | |
| TTLStrategy, | |
| ) | |
| __all__ = [ | |
| # Core classes | |
| "HybridCache", | |
| "InMemoryCache", | |
| "CacheBackend", | |
| "CacheDataType", | |
| "CacheStats", | |
| "CacheKey", | |
| "TTLStrategy", | |
| "PortfolioCachingStrategy", | |
| "CacheInvalidationManager", | |
| "FinancialDataCacheManager", | |
| # Factory and convenience functions | |
| "CacheFactory", | |
| "get_cache", | |
| "get_cache_manager", | |
| # Global instances | |
| "cache", | |
| "cache_manager", | |
| # Decorators | |
| "cached", | |
| "cached_async", | |
| "cache_invalidate", | |
| ] | |