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

Exclude parameters from memoize cache key #16

Closed
sallyruthstruik opened this issue Dec 26, 2016 · 1 comment
Closed

Exclude parameters from memoize cache key #16

sallyruthstruik opened this issue Dec 26, 2016 · 1 comment

Comments

@sallyruthstruik
Copy link

There are several cases when you may want to exclude some parameters from cache key generation. For example:

@cache.memoize(timeout=1000)
def search(title, softIds):
    #some search stuff

search("Title 1", {1, 2, 3})
search("Title 1", {3, 2, 1})

in this case we want second search to be taken from cache, but it didn't. I propose this solution:

@cache.memoize(timeout=1000, exclude_params=["softIds"])
def search(title, softIds):
    #some search stuff

exclude_params - array of parameter names which should be excluded from key generation. So key will be based only on "title" parameter, and second search will be taken from cache.

@sallyruthstruik
Copy link
Author

Added pull request #9

@sallyruthstruik sallyruthstruik changed the title Exclude parameters from _memoize_make_cache_key Exclude parameters from memoize cache key Dec 26, 2016
@sh4nks sh4nks closed this as completed Feb 2, 2017
sallyruthstruik added a commit to sallyruthstruik/flask-caching that referenced this issue Feb 9, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants