From 12330dd6041b9a4ee66571dca845947988e6f474 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sun, 26 Jan 2020 22:36:24 +0000 Subject: [PATCH] cachew demo for reddit --- my/reddit.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/my/reddit.py b/my/reddit.py index c7f9a47..37451c3 100755 --- a/my/reddit.py +++ b/my/reddit.py @@ -28,11 +28,6 @@ def get_sources() -> Sequence[Path]: return tuple(res) -def dal(): - # TODO lru cache? but be careful when it runs continuously - return rexport.DAL(get_sources()) - - logger = LazyLogger('my.reddit', level='debug') @@ -43,19 +38,27 @@ Submission = rexport.Submission Upvote = rexport.Upvote -# TODO cachew? wonder how to play nicely with DAL? +def dal(): + # TODO lru cache? but be careful when it runs continuously + return rexport.DAL(get_sources()) + + +@mcachew(hashf=lambda: get_sources()) def saved() -> Iterator[Save]: return dal().saved() +@mcachew(hashf=lambda: get_sources()) def comments() -> Iterator[Comment]: return dal().comments() +@mcachew(hashf=lambda: get_sources()) def submissions() -> Iterator[Submission]: return dal().submissions() +@mcachew(hashf=lambda: get_sources()) def upvoted() -> Iterator[Upvote]: return dal().upvoted()