logging for why milb api isn't working and cache updates to odds cache storage

This commit is contained in:
Chuck
2025-08-02 20:02:52 -05:00
parent 13a2ef6e5e
commit ac69569d77
5 changed files with 15 additions and 360 deletions

View File

@@ -16,8 +16,8 @@ class OddsManager:
def get_odds(self, sport: str, league: str, event_id: str, update_interval_seconds=3600):
cache_key = f"odds_espn_{sport}_{league}_{event_id}"
# Check cache first with 1-hour update interval
cached_data = self.cache_manager.get(cache_key)
# Check cache first
cached_data = self.cache_manager.get_with_auto_strategy(cache_key)
if cached_data:
self.logger.info(f"Using cached odds from ESPN for {cache_key}")
@@ -37,12 +37,12 @@ class OddsManager:
self.logger.info(f"Extracted odds data: {odds_data}")
if odds_data:
self.cache_manager.update_cache(cache_key, odds_data)
self.cache_manager.set(cache_key, odds_data)
self.logger.info(f"Saved odds data to cache for {cache_key}")
else:
self.logger.warning(f"No odds data extracted for {cache_key}")
# Cache the fact that no odds are available to avoid repeated API calls
self.cache_manager.update_cache(cache_key, {"no_odds": True})
self.cache_manager.set(cache_key, {"no_odds": True})
return odds_data
@@ -51,7 +51,7 @@ class OddsManager:
except json.JSONDecodeError:
self.logger.error(f"Error decoding JSON response from ESPN API for {cache_key}.")
return self.cache_manager.get(cache_key)
return self.cache_manager.get_with_auto_strategy(cache_key)
def _extract_espn_data(self, data: Dict[str, Any]) -> Optional[Dict[str, Any]]:
self.logger.debug(f"Extracting ESPN odds data. Data keys: {list(data.keys())}")