Introduce Flipper::Adapters::FallbackToCached#860
Open
jonmagic wants to merge 1 commit intoflippercloud:mainfrom
Open
Introduce Flipper::Adapters::FallbackToCached#860jonmagic wants to merge 1 commit intoflippercloud:mainfrom
jonmagic wants to merge 1 commit intoflippercloud:mainfrom
Conversation
7f1a555 to
862af8e
Compare
862af8e to
0bc8cb9
Compare
Collaborator
|
I think my only issue with this is the inheriting from memorizable and turning memoize off. It might be just because I haven't started from scratch on it to see how much is shared. I think I'll take a stab at it from scratch to see the difference. |
Author
I think you have to turn this off or it will add the memoizable adapter as the first in the stack and it defeats the purpose of this change. |
Collaborator
|
Memoizable usually just sits in front and falls back to the original adapter. So if your original falls back to in memory cache it should just work. Maybe something else weird was at play. I'll have to kick the tires. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why?
For my use case I need to be able to cache values each time
features,get,get_multi, orget_allare called but only use those cached values if subsequent calls to them fail. It should raise an error if no cached values are there to use.How?
I introduced a new adapter called
Flipper::Adapters::FallbackToCachedthat inherits from the Memoizable adapter and wraps another adapter. It updates the implementation offeatures,get,get_multi, andget_allto call the primary adapter and caches the values. If the primary adapter raises an error, it will return the cached value instead. If there is no cached value, it will raise the error.Please note you have to disable memoize when configuring Flipper so that it doesn't use the Memoizable adapter like it normally would.