mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-13 14:03:00 +00:00
type error fix : remote ttl
This commit is contained in:
@@ -376,7 +376,11 @@ class CacheManager:
|
|||||||
|
|
||||||
def set(self, key: str, data: Dict) -> None:
|
def set(self, key: str, data: Dict) -> None:
|
||||||
"""Store data in cache with current timestamp."""
|
"""Store data in cache with current timestamp."""
|
||||||
self.save_cache(key, data)
|
cache_data = {
|
||||||
|
'data': data,
|
||||||
|
'timestamp': time.time()
|
||||||
|
}
|
||||||
|
self.save_cache(key, cache_data)
|
||||||
|
|
||||||
def setup_persistent_cache(self) -> bool:
|
def setup_persistent_cache(self) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ class OddsTickerManager:
|
|||||||
else:
|
else:
|
||||||
ttl = 43200 # 12 hours for future dates
|
ttl = 43200 # 12 hours for future dates
|
||||||
|
|
||||||
data = self.cache_manager.get(cache_key)
|
data = self.cache_manager.get(cache_key, max_age=ttl)
|
||||||
|
|
||||||
if data is None:
|
if data is None:
|
||||||
url = f"https://site.api.espn.com/apis/site/v2/sports/{sport}/{league}/scoreboard?dates={date}"
|
url = f"https://site.api.espn.com/apis/site/v2/sports/{sport}/{league}/scoreboard?dates={date}"
|
||||||
@@ -342,7 +342,7 @@ class OddsTickerManager:
|
|||||||
response = requests.get(url, timeout=self.request_timeout)
|
response = requests.get(url, timeout=self.request_timeout)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
data = response.json()
|
data = response.json()
|
||||||
self.cache_manager.set(cache_key, data, ttl=ttl)
|
self.cache_manager.set(cache_key, data)
|
||||||
logger.debug(f"Cached scoreboard for {league} on {date} with a TTL of {ttl} seconds.")
|
logger.debug(f"Cached scoreboard for {league} on {date} with a TTL of {ttl} seconds.")
|
||||||
else:
|
else:
|
||||||
logger.debug(f"Using cached scoreboard data for {league} on {date}.")
|
logger.debug(f"Using cached scoreboard data for {league} on {date}.")
|
||||||
|
|||||||
Reference in New Issue
Block a user