From 006e35cc877d19e7fc733a6ee8cae83f2457b6b2 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Wed, 28 Aug 2019 16:21:08 +0200 Subject: [PATCH] attemt to use cachew --- reddit/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/reddit/__init__.py b/reddit/__init__.py index f66efd3..4c3169c 100755 --- a/reddit/__init__.py +++ b/reddit/__init__.py @@ -40,6 +40,8 @@ class Save(NamedTuple): title: str sid: Sid 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): return hash(self.sid) @@ -70,10 +72,12 @@ class Save(NamedTuple): return self.json['subreddit']['display_name'] -class Misc(NamedTuple): - pass +# class Misc(NamedTuple): +# pass -EventKind = Union[Save, Misc] +# EventKind = Union[Save, Misc] + +EventKind = Save class Event(NamedTuple): dt: datetime @@ -140,6 +144,9 @@ def _get_state(bfile: Path) -> Dict[Sid, Save]: ) 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) def _get_events(backups: Sequence[Path], parallel: bool) -> List[Event]: