mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 21:03:01 +00:00
cache updates
This commit is contained in:
@@ -57,6 +57,10 @@ class BaseMLBManager:
|
||||
if not self.show_odds:
|
||||
return
|
||||
|
||||
# Skip if odds are already attached to this game
|
||||
if 'odds' in game and game['odds']:
|
||||
return
|
||||
|
||||
try:
|
||||
game_id = game.get('id', 'N/A')
|
||||
self.logger.info(f"Requesting odds for game ID: {game_id}")
|
||||
|
||||
@@ -16,15 +16,14 @@ 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}"
|
||||
|
||||
# Temporarily disable cache to force a fresh API call for debugging
|
||||
cached_data = None
|
||||
# cached_data = self.cache_manager.get_cached_data(cache_key, max_age=update_interval_seconds)
|
||||
# Check cache first with 1-hour update interval
|
||||
cached_data = self.cache_manager.get_cached_data(cache_key, max_age=update_interval_seconds)
|
||||
|
||||
if cached_data:
|
||||
self.logger.info(f"Using cached odds from ESPN for {cache_key}")
|
||||
return cached_data
|
||||
|
||||
self.logger.info(f"Fetching fresh odds from ESPN for {cache_key}")
|
||||
self.logger.info(f"Cache miss - fetching fresh odds from ESPN for {cache_key}")
|
||||
|
||||
try:
|
||||
url = f"{self.base_url}/{sport}/leagues/{league}/events/{event_id}/competitions/{event_id}/odds"
|
||||
@@ -39,6 +38,9 @@ class OddsManager:
|
||||
|
||||
if odds_data:
|
||||
self.cache_manager.save_cache(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}")
|
||||
|
||||
return odds_data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user