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

Request-level caching #5

Open
smiley opened this issue Dec 7, 2013 · 10 comments
Open

Request-level caching #5

smiley opened this issue Dec 7, 2013 · 10 comments

Comments

@smiley
Copy link
Owner

smiley commented Dec 7, 2013

As more and more issues in making this object-oriented become apparent, a suggested solution would be to use caching on actual API calls: If the exact same call is done before a specified time has passed, a cached copy of the API call should be given instead.

Certainly better than Singletons and two-way binding things...

@zoidyzoidzoid
Copy link

Hi, Sorry, just started looking at this project. What about using: https://github.com/mailgun/expiringdict for caching the requests?

@smiley
Copy link
Owner Author

smiley commented Dec 11, 2013

That's actually what I'm currently using for caching object properties. What I proposed on this issue is to move caching from properties to requests, so I could cache the raw data used by many rather than every object's finished, parsed product.

@oxivanisher
Copy link

I would really like this. :) Or is there a workaround for it to simulate this behavior?

@zoidyzoidzoid
Copy link

What about using something like https://github.com/reclosedev/requests-cache ?

@smiley
Copy link
Owner Author

smiley commented Sep 19, 2014

@zoidbergwill I'll have a look at it. Thanks!

@zoidyzoidzoid
Copy link

I'll happily make a PR with it. if you like?

@smiley
Copy link
Owner Author

smiley commented Sep 19, 2014

You can, but from the looks of it I'll have to rework the storage of requests-cache into something memory-based, since it uses SQLite. (And this caching will be temporary, so something as big as a persistent database is too heavy)

@zoidyzoidzoid
Copy link

Yeah, there are easier ways to do it, without the library. If you wanna do in-memory caching.

That makes sense since it doesn't really need to store it between instances.

@ghost
Copy link

ghost commented Sep 20, 2014

sqlite should be able to run in memory (filename = ":memory:"), unfortunately they seem to be forcing any name entered to become "XXX.sqlite", (even though the docstring for DbDict says not to)

self.keys_map = DbDict(location + extension, 'urls')

regardless, @smiley they do have a in-memory cache, the base one, so that might work for your needs

https://github.com/reclosedev/requests-cache/blob/master/requests_cache/backends/base.py

and should be accessible via requests_cache.install_cache('',backend='base').

@oxivanisher
Copy link

Can I help with this in any way? Testing for example?

@smiley smiley changed the title Maybe caching should be done at the request-level? Request-level caching Oct 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants