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

Add a runtime prefix to default cache key #163

Open
jojurajan opened this issue May 3, 2021 · 3 comments
Open

Add a runtime prefix to default cache key #163

jojurajan opened this issue May 3, 2021 · 3 comments

Comments

@jojurajan
Copy link

I am using ring.redis==0.7.3 for caching function returns and I need to prefix the cache key based on the environment that code is being deployed.

Currently it is not possible to set the key_refactor method during runtime because of the way compose_key method has been implemented. https://github.com/youknowone/ring/blob/0.7.3/ring/func/base.py#L648

Is there a way to specify the key_refactor method during runtime without re-implementing create_key_builder locally?

@youknowone
Copy link
Owner

I can't see a good solution for now. I think refactoring create_key_builder to class would be the one of the future.

@jojurajan
Copy link
Author

Instead of overriding the key_refactor method, I added the custom prefix to _key_prefix value.

In case someone else is looking for this, the gist can be found here

@youknowone
Copy link
Owner

let me keep this issue open to make them customizable. I think this is lack of feature.

@youknowone youknowone reopened this May 4, 2021
@jojurajan jojurajan changed the title Runtime configuration of key_refactor function Add a runtime prefix to default cache key May 5, 2021
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

2 participants