This commit is contained in:
doms9 2025-09-04 11:50:29 -04:00
parent 8ece1961e0
commit 00000d91c9
2 changed files with 21 additions and 13 deletions

View file

@ -64,13 +64,17 @@ async def get_cert(client: httpx.AsyncClient) -> ssl.SSLContext:
return ssl.create_default_context(cafile=CERT_FILE)
def load_cache() -> dict[str, dict[str, str | str]]:
def load_cache() -> dict[str, dict[str, str | float]]:
try:
data: dict = json.loads(CACHE_FILE.read_text(encoding="utf-8"))
data: dict[str, dict[str, str | float]] = json.loads(
CACHE_FILE.read_text(encoding="utf-8")
)
age: float = now.timestamp() - data.get("timestamp", 0)
return {k: v for k, v in data.items() if age < 14400} # 4 hours
return {
k: v
for k, v in data.items()
if now.timestamp() - data[k].get("timestamp", 0) < 14400 # 4 hours
}
except (FileNotFoundError, json.JSONDecodeError):
return {}