Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache support? #1140

Closed
frankdilo opened this issue Nov 22, 2019 · 3 comments
Closed

Cache support? #1140

frankdilo opened this issue Nov 22, 2019 · 3 comments

Comments

@frankdilo
Copy link

frankdilo commented Nov 22, 2019

Issue Description

Hi, I saw that you remove caching support in 2016 and that now just some properties are cached via the cachedproperty decorator. I was interested in caching the results I get via the subreddit.top("day") method.

What's your suggested way to do that?

System Information

  • PRAW Version: 6.4.0
  • Python Version: 3.7.4
  • Operating System: macOS Catalina

p.s. Love what you are doing with this library, thanks for all your work ❤️

@bboe
Copy link
Member

bboe commented Dec 2, 2019

Hi @frankdilo, can you provide more information about your reason for wanting to cache top("day") listing?

@PythonCoderAS
Copy link
Contributor

PythonCoderAS commented Jan 10, 2020

I would say to manually cache yourself through a dict:

from time import time

cache_dict = {"timestamp": 0, "data": None}

if int(time())-cache_dict["timestamp"] >= 60 * 60 * 1: # 1 hour, modify 1 to modify hours
    cache_dict["data"] = reddit.subreddit("TEST").top("day")

@bboe
Copy link
Member

bboe commented Jan 10, 2020

Closing due to inactivity. Please include an answer to the above question if you think this is still worthwhile. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants