attemt to use cachew
This commit is contained in:
parent
f151e49574
commit
006e35cc87
1 changed files with 10 additions and 3 deletions
|
@ -40,6 +40,8 @@ class Save(NamedTuple):
|
||||||
title: str
|
title: str
|
||||||
sid: Sid
|
sid: Sid
|
||||||
json: Any = None
|
json: Any = None
|
||||||
|
# TODO ugh. not sure how to support this in cachew... could try serializing dicts of simple types automatically.. but json can't be properly typed
|
||||||
|
# TODO why would json be none?
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(self.sid)
|
return hash(self.sid)
|
||||||
|
@ -70,10 +72,12 @@ class Save(NamedTuple):
|
||||||
return self.json['subreddit']['display_name']
|
return self.json['subreddit']['display_name']
|
||||||
|
|
||||||
|
|
||||||
class Misc(NamedTuple):
|
# class Misc(NamedTuple):
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
EventKind = Union[Save, Misc]
|
# EventKind = Union[Save, Misc]
|
||||||
|
|
||||||
|
EventKind = Save
|
||||||
|
|
||||||
class Event(NamedTuple):
|
class Event(NamedTuple):
|
||||||
dt: datetime
|
dt: datetime
|
||||||
|
@ -140,6 +144,9 @@ def _get_state(bfile: Path) -> Dict[Sid, Save]:
|
||||||
)
|
)
|
||||||
return OrderedDict()
|
return OrderedDict()
|
||||||
|
|
||||||
|
# from cachew import cachew
|
||||||
|
# TODO hmm. how to combine cachew and lru_cache?....
|
||||||
|
# @cachew('/L/data/.cache/reddit-events.cache')
|
||||||
|
|
||||||
@lru_cache(1)
|
@lru_cache(1)
|
||||||
def _get_events(backups: Sequence[Path], parallel: bool) -> List[Event]:
|
def _get_events(backups: Sequence[Path], parallel: bool) -> List[Event]:
|
||||||
|
|
Loading…
Add table
Reference in a new issue