e
This commit is contained in:
parent
c090e6d0be
commit
00000d922c
6 changed files with 417 additions and 7 deletions
|
|
@ -17,7 +17,11 @@ class Cache:
|
|||
|
||||
return self.now_ts - dt_ts < self.exp
|
||||
|
||||
def load(self, per_entry: bool = True) -> dict[str, dict[str, str | float]]:
|
||||
def load(
|
||||
self,
|
||||
per_entry: bool = True,
|
||||
index: bool = False,
|
||||
) -> dict[str, dict[str, str | float]]:
|
||||
try:
|
||||
data: dict = json.loads(self.file.read_text(encoding="utf-8"))
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
|
|
@ -26,7 +30,11 @@ class Cache:
|
|||
if per_entry:
|
||||
return {k: v for k, v in data.items() if self.is_fresh(v)}
|
||||
|
||||
ts: float | int = data.get("timestamp", 31496400)
|
||||
if index:
|
||||
ts: float | int = data[0].get("timestamp", 31496400)
|
||||
|
||||
else:
|
||||
ts: float | int = data.get("timestamp", 31496400)
|
||||
|
||||
dt_ts = Time.clean(Time.from_ts(ts)).timestamp()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue