-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Prefetch syncs to redis #1446
Draft
kwitsch
wants to merge
25
commits into
0xERR0R:main
Choose a base branch
from
kwitsch:issues/1422
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+402
−299
Draft
Prefetch syncs to redis #1446
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a411c5f
reloadCacheEntry removes edns and publishes to redis
kwitsch 6a89907
Update resolver/caching_resolver.go
kwitsch 8607144
added transformAndPublish
kwitsch 43e59a4
wip
kwitsch 5eb351f
dns util rework
kwitsch 0f6c847
fixed generics
kwitsch 27c60e7
linebreaks in doctag
kwitsch 7f39983
refactoring
kwitsch 66a7155
added ToTTLDuration
kwitsch 6de43c8
added fast returns to reduce loops
kwitsch 46441ba
fast return and comments
kwitsch f28e58c
added dns unit tests
kwitsch 5dc3a16
no fast return since adjustment is needed to set minttl
kwitsch afbb305
Merge branch 'main' into issues/1422
kwitsch 37fbb42
use correct context
kwitsch 350b2fe
redis refactoring 1
kwitsch 423ed03
caching_resolver refactoring
kwitsch 4928399
redis refactoring 2
kwitsch 17aca2c
fast return on zero or below
kwitsch 05446fa
redis refactoring
kwitsch c798689
fix caching resolver test
kwitsch f8093f3
nil check
kwitsch 61c83af
new pointers
kwitsch 73cbd9c
removed const
kwitsch 7b2fcc2
redis refactoring 2
kwitsch 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
Loading status checks…
added ToTTLDuration
commit 66a7155650f4eac2c6dd7ab56c60569653baa39d
There are no files selected for viewing
This file contains 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 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.
I think the biggest cause of dupe code is that here we need to return the new cache entry,
but in
r.Resolver
we need to callr.resultCache.Put
.So we could change the prefetch API to be more like the normal caching flow:
PrefetchingOptions.ReloadFn func(ctx context.Context, key string) (*T, time.Duration)
could be something like
OnAboutToExpire func(ctx context.Context, key string)
,where the callback is expected to call
Put
if they want to update the value.That way
reloadCacheEntry
could become a tiny wrapper aroundr.Resolve
(or a newresolve
method they both call).From a quick check,
ReloadFn
is only used by this code (and the cache tests),and
Put
allows replacing a value, so I think that should be doable!From there I think most things will fall into place :)
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.
Thanks for the input I think that was the part which caused me the most headaches. 😅
I also try to refactor the caches to streamline the resolver behavior. 👍