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

Setup cache from URL for decorators #502

Closed
jerr0328 opened this issue Jul 12, 2020 · 2 comments
Closed

Setup cache from URL for decorators #502

jerr0328 opened this issue Jul 12, 2020 · 2 comments

Comments

@jerr0328
Copy link

jerr0328 commented Jul 12, 2020

In #428 (PR: #432), the feature to create a cache from URLs was added. I would like to also be able to use this with decorators, which seems to currently not support this. I imagine there's a few ways of tackling this:

  1. Adding direct support in the decorator. I would imagine a way to define the decorator with a kwarg like from_url which would then set up the cache based on the URL passed in.
  2. Passing in a Cache object that was set up with Cache.from_url, meaning either a new kwarg or overloading the existing cache arg to take either a class or an object.
  3. Changing the config structure to allow configuration with URL. For instance, defining a key with just one key/value of from_url and the URL (and other options like plugins and serializers of course). This would allow the decorator code to remain unchanged and simply use the alias feature already implemented.

I'd be happy to open a PR for any option (including something I missed).

Edit: This is also somewhat relevant to #450

@argaen
Copy link
Member

argaen commented Oct 15, 2020

Hey @jerr0328, maybe I would go for passing url param to the decorator and then inside the decorator create the instance with Cache.from_url which would be quite easy.

You make a point about adding support to use urls in the config but this would be a different feature that we can also add.

Feel free to contribute back please, happy to review! :)

@Dreamsorcerer
Copy link
Member

I think with #609 in mind, this won't be relevant after that's solved. You'll likely need to pass a cache object to the decorator, which is essentially your option 2.

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