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

Allow users to define its own set of Cacheable Status Code when using Faraday Middleware Cache #275

Merged
merged 6 commits into from
Oct 13, 2021

Conversation

Physium
Copy link
Contributor

@Physium Physium commented Oct 12, 2021

This implementation allows users to define its own set of status codes for caching as opposed to sticking to a set of predefined CACHEABLE_STATUS_CODE constant. Nonetheless, user defined status code has to be within the list of predefined CACHEABLE_STATUS_CODE constant.

… be within CACHEABLE_STATUS_CODE pre-defined constant values
Copy link
Member

@iMacTia iMacTia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Physium thank you so much for submitting this PR 🙌 !
The overall implementation works and tests are already passing, but I highlighted a few things I'd like to change before merging.
I hope this will be a good opportunity to learn a few things.

Please also remember to add the new option to the initialize method documentation as well 🙏 !

lib/faraday_middleware/response/caching.rb Outdated Show resolved Hide resolved
lib/faraday_middleware/response/caching.rb Outdated Show resolved Hide resolved
lib/faraday_middleware/response/caching.rb Outdated Show resolved Hide resolved
lib/faraday_middleware/response/caching.rb Outdated Show resolved Hide resolved
1. memozied method to prevent unnecessary calls when called multiple times
2. shift logic into custom_status_codes
3. rename custom_status_code to custom_status_codes
@iMacTia
Copy link
Member

iMacTia commented Oct 13, 2021

Thank you @olleolleolle, that's a great suggestion!
@Physium while you make that change, could you please also rename the new option to plural so that it's @options[:status_codes]? It's shorter and it looks nicer when adding the middleware.
I think that will help remove confusion between the option and the CACHEABLE_STATUS_CODES constant.
(remember to update the initialize documentation after this change)

Copy link
Member

@iMacTia iMacTia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Physium It looks great 💪 , thanks for incorporating all our comments 🙌!
LGTM 🎉 !

@iMacTia iMacTia merged commit 784b4f8 into lostisland:main Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants