-
Notifications
You must be signed in to change notification settings - Fork 167
LG-7814: Cache USPS auth token as class member #7147
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
Merged
sheldon-b
merged 9 commits into
main
from
sbachstein/lg-7814-cache-usps-auth-token-as-class-member
Oct 18, 2022
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
55ed59e
Use class members instead of instance members
248de40
Refresh token if it has less than 1 second left
633e743
Initialize class member variables
d1eb342
Revert "Refresh token if it has less than 1 second left"
26b6e9e
changelog: Upcoming Features, In-person proofing, Cache usps api toke…
c7f3a06
Use mattr_reader so members are readable in spec
0800018
Update app/services/usps_in_person_proofing/proofer.rb
c8043f5
Update app/services/usps_in_person_proofing/proofer.rb
7612e69
Update app/services/usps_in_person_proofing/proofer.rb
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would it be safe to use
Rails.cachefor this to share across instances?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.
I think so but is there a benefit to that over a class member?
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.
Class members can be hard to test/reason about sometimes
mattr_readervscattr_readerand then have to be reset explicitly in tests, butRails.cachehas easy methods for clearing it.Also with like 10+ boxes, with probably 4+ processes each, each one will have to cache separately, so having a shared cache (we use Redis to back our
Rails.cache) might save extra requests to the API overallThere 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.
Oh cool it's shared across processes and instances? Yeah I'll go ahead and switch it to
Rails.cacheThere 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.
in prod, yes!, locally it might just be in-memory
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.
Oops, seeing this conversation after PRing an identical approach. @sheldon-b will this be updated in a future PR? maybe we can pair on this and this one ...
Uh oh!
There was an error while loading. Please reload this page.
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.
Yeah the original ticket is already marked Done and shipped to prod. I've created LG-7918 to move the caching to the rails cache
Happy to pair! I'll bring LG-7918 to refinement today