-
-
Notifications
You must be signed in to change notification settings - Fork 194
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 make_cache_key
parameter
#159
Conversation
library consumers can now set their own make_cache_key attribute of the returned cache decorator, accomidating use cases such as the one in Issue 71 without even needing to change the public API since this attribute has been documented read/write for years.
Hmm, CI has failed some tests that are passing locally for me, I guess I'll have to figure out why first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the failing tests, it looks good to me. Let us know if you need help with the tests, i might be able to help tomorrow (CET)
Thanks for the offer, but I think I'm fine to figure it out on my own, I'm able to reproduce the failures in a docker container, so I'll just debug them and then push a fix |
This is technically a breaking API change, although a very small one, it will have to be decided if that's okay.
I figured out the problem, but unfortunately the fix technically makes this a very small API change that could technically result in incompatibilities with previous versions. The There is however a case where this will break a previously valid use case, where the caller was using the That is a very specific and probably unlikely scenario, but it is technically possible that this would now break existing code. We'll have to decide if that's okay or not. |
This change replaces the previous method of using the existing make_cache_key attribute of the returned decorator since that method required that a slight behavioral change to that method be introduced, which technically breaks backwards compatibility
I've pushed a change so that this no longer works off of the This isn't as slick a solution as the previous one, but after thinking it over there's no real reason to break compatibility, even in a very small corner case, when it can just be done this way. Especially since if it ever did affect anyone, it would be almost impossible to debug on their part without inspecting the source of this library and really understanding what it was doing. Also I noticed a bug in the test, so that has also been fixed. I've edit the PR name/description to reflect this. |
make_cache_key
parameter
Not sure why the tests are timing out in the first memcached test, I get no problems with them on my machine
|
Wanna ask when will flask-caching merge this PR, this feature is life-saver. |
I am having the same problem on my machine but when I started the tests a second time everything went fine. I believe it has something to do with the startup of the memcache server. Thanks for this PR @buckley-w-david! |
Thanks a lot @buckley-w-david @sh4nks @gergelypolonkai 👍 |
This PR is essentially a more considered version of #76
After the additional discussion with @bzed I changed my stance on the functionality, but actually even further it seemed like what the library actually needed was a way to allow the consumer complete control over the cache key generation if they so wished.
I have added a
make_cache_key
parameter to thecached
decorator for this purpose.This should allow for use cases such as #71, an example of which is in the test added in this PR