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

Support skip nil for cache fetch #25437

Merged
merged 5 commits into from Aug 5, 2018

Conversation

Martin91
Copy link
Contributor

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.

@rails-bot
Copy link

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.

@Martin91
Copy link
Contributor Author

@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?
image

@maclover7
Copy link
Contributor

@Martin91 nope, master is failing right now. will be green again once #25436 is merged in.

@Martin91
Copy link
Contributor Author

Ok, glad to sound that
Jon Moss notifications@github.com于2016年6月20日 周一上午4:47写道:

@Martin91 https://github.com/Martin91 nope, master is failing right
now. will be green again once #25436
#25436 is merged in.


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#25437 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ACxCpKLXM2gFzZjwftWLAEcHVl6VWvGIks5qNar6gaJpZM4I5GPQ
.

@Martin91
Copy link
Contributor Author

I wonder if anyone has any opinion on this PR?

@schneems
Copy link
Member

This seems fine. Can you fix the conflicts?

@Martin91
Copy link
Contributor Author

@schneems Sure.

@Martin91 Martin91 force-pushed the support-skip-nil-for-cache-fetch branch 3 times, most recently from 8a56996 to 77ebe11 Compare July 23, 2018 16:20
@Martin91
Copy link
Contributor Author

@schneems I have rebased the branch and resolved the conflicts.

@schneems
Copy link
Member

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!

@Martin91 Martin91 force-pushed the support-skip-nil-for-cache-fetch branch from 003973e to 4bb7e63 Compare August 5, 2018 03:45
@Martin91
Copy link
Contributor Author

Martin91 commented Aug 5, 2018

@schneems I have added a change log entry and it seems that all tests have passed.

@schneems
Copy link
Member

schneems commented Aug 5, 2018

Thanks!

@schneems schneems merged commit 47018a8 into rails:master Aug 5, 2018
@rlue
Copy link
Contributor

rlue commented Oct 20, 2019

This feature was announced here as a feature of Rails 5.2.1, but it appears to be absent from the 5-2-stable branch—have I missed something? If not, is there any chance we could get it backported?

@rlue rlue unassigned sgrif Oct 20, 2019
@kamilpp
Copy link

kamilpp commented Feb 3, 2020

I confirm that skip_nil option is not present in Rails 5.2, despite it was announced so

@rafaelfranca
Copy link
Member

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?

@rlue
Copy link
Contributor

rlue commented Feb 25, 2020

Ah, so that's how it works! My mistake.

@leoplct
Copy link

leoplct commented Aug 29, 2022

How can I pass a boolean variable to force skipping the cache?
At the moment I can pass {force: true} but this will cache results. I am looking to not read/save cache where some conditions applies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants