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
Support skip nil for cache fetch #25437
Support skip nil for cache fetch #25437
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@sgrif @maclover7 I saw some build failures in ci but I think they are not related to my PR, should I pay attention to or am responsible for them? |
Ok, glad to sound that
|
I wonder if anyone has any opinion on this PR? |
This seems fine. Can you fix the conflicts? |
@schneems Sure. |
8a56996
to
77ebe11
Compare
@schneems I have rebased the branch and resolved the conflicts. |
Tests are failing, can you take a look. Also I’ll need a change log entry for this. We are getting close, thanks for your work here! |
003973e
to
4bb7e63
Compare
@schneems I have added a change log entry and it seems that all tests have passed. |
Thanks! |
This feature was announced here as a feature of Rails 5.2.1, but it appears to be absent from the |
I confirm that |
It was not announced as part of 5.2. It was announced in the same email saying that 5.2.1 was released but nothing there say it is part of 5.2. Am I missing something? |
Ah, so that's how it works! My mistake. |
How can I pass a boolean variable to force skipping the cache? |
Summary
Provide a
skip_nil
setting for cache store. According to our cases, we need to cache some results retrieved from external services with 1 day expiration time, but if they are down with some accidental reasons, nil result will be cached whole day, instead, we hope not to cache that result, so we can always retry retrieving and it can cache expected result again once the services come back normal.I have added one more spec for this setting and it ensures not to break existed behaviours, I also updated the documentation for #fetch method.