File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 66"""
77
88import logging
9- import time
109from datetime import datetime , timedelta
1110from typing import Any , Dict , Optional
1211
1918logger = logging .getLogger (__name__ )
2019
2120# Cache for storing financial analysis results (session-level)
21+ # Note: This cache grows indefinitely. In production, consider implementing:
22+ # - Cache size limits (e.g., LRU eviction)
23+ # - TTL-based expiration for stale data
24+ # - Periodic cleanup in long-running applications
25+ # For typical Streamlit sessions, this is acceptable as the cache is cleared
26+ # on app restart and session_state provides the primary cache layer.
2227_CACHE = {}
2328
2429
@@ -240,6 +245,11 @@ def analyze_financial_asset(
240245 result_json = response .model_dump_json ()
241246
242247 # Cache the successful result
248+ # Note: Error responses are intentionally NOT cached because:
249+ # 1. Transient errors (network issues, API rate limits) should be retried
250+ # 2. Invalid tickers fail fast (symbol resolution is quick)
251+ # 3. Caching errors could hide resolved issues
252+ # If error caching is needed, implement with short TTL and proper invalidation
243253 if use_cache :
244254 _set_cached_analysis (ticker , years , result_json )
245255
You can’t perform that action at this time.
0 commit comments