-
Notifications
You must be signed in to change notification settings - Fork 62
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
Feature Request: Cache invalidation / hash change on decorated function code change #34
Comments
Hey. Please see my comments on your PR, #35 . |
No Worries, it was just a quick way to add source code to the hash function. Unfortunately (and this is not a dig because cachier is a very nice package), cachier doesn't seem to work with class functions. This is a big use case for me and really don't have a deep understanding of cachier for the enhancement. Maybe you would consider adding the enhancement? :) |
I would also like this feature. Personally, I would prefer it to default-on (with configuration to turn it off), because that seems like the most sensible situation to me. If you change the code in your function, then obviously it is going to change some of the results; and if those results are already persisted, then you are going to get incorrect results. I understand the concerns about whitespace or comment/documentation changes; but that sounds like an optimization to me. I really like this project, but the first time I used it for anything interesting, I found myself renaming my function a half-dozen times to force the cache to reset after fixing some obvious bugs in the function. I ended up writing a manual wrapper function to preserve the external interface. Although, I should point out that hashing the source code is not a perfect solution: if it calls other functions that have changed, then it will not reset the cache. To be pedantic, it would be nice to have an option to pass a list of called functions to the decorator, which will all be added to the hash for the source code. It might be error prone, but it at least gives the ability to handle these types of changes. |
Still, I agree it's a great feature. It just requires some real work and extensive testing for edge cases, so someone has to pitch in, or I'll just get to it if enough people nag me about it and I get some time. :) |
Also, note that any change will have to overcome the problem discovered in #35 , which forced a version rollback. |
Just leaving here an updates status: This is an often-requested feature which is way more complex than it seems initially. This was discussed in the following issues: And attempted in two separate pull requests: I would absolutely LOVE it if someone would like to make a contribution to help with this feature. Any such potential contributor, however, would have to start with getting up-to-date with past discussions, issues and attempted contributions. Please continue all related discussion there. Cheers, |
Hi, I was wondering if it's possible to include the function code in the cache? That is, if I make a change to the function code, the function will not serve from cache. Thanks for any advice.
The text was updated successfully, but these errors were encountered: