This repository was archived by the owner on Aug 12, 2021. It is now read-only.
delete entries from the cache when the TTL expires - #6
Open
marten-seemann wants to merge 4 commits into
Open
Conversation
marten-seemann
force-pushed
the
cleanup-after-ttl2
branch
3 times, most recently
from
July 2, 2021 21:11
a86344a to
216fbdc
Compare
Stebalien
approved these changes
Jul 2, 2021
Stebalien
left a comment
Collaborator
There was a problem hiding this comment.
I would have done this slightly differently, but either way works.
| }, nil | ||
| } | ||
|
|
||
| var cleanupFreq = 10 * time.Second |
Collaborator
There was a problem hiding this comment.
Nit: can probably be on the order of minutes. But not really an issue any which way.
| sentEntries = make(map[string]*ServiceEntry) | ||
| var entries map[string]*ServiceEntry | ||
| c.sentEntries = make(map[string]*ServiceEntry) | ||
| go c.cleanupSentEntries(ctx) |
Collaborator
There was a problem hiding this comment.
nit: consider doing this inline? There's no real reason to have another loop, and it saves us a lock & shared state.
Owner
Author
There was a problem hiding this comment.
That's more than just a nit. That's a major simplification!
Collaborator
There was a problem hiding this comment.
nit == not really necessary but maybe nice to have. But yeah, it's cleaner now.
marten-seemann
force-pushed
the
cleanup-after-ttl2
branch
from
July 3, 2021 01:45
216fbdc to
3e3e44e
Compare
marten-seemann
force-pushed
the
cleanup-after-ttl2
branch
from
July 4, 2021 21:37
3e3e44e to
6724681
Compare
marten-seemann
force-pushed
the
cleanup-after-ttl2
branch
from
July 4, 2021 21:39
6724681 to
72b80e6
Compare
Owner
Author
|
Rebased on top of #9, which (among other things) implements a clean shutdown. This fixes the race conditions we encountered earlier with this PR. |
Stebalien
approved these changes
Jul 4, 2021
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This is a copy of grandcat#93.
Instead of saving the TTL value (an integer, measuring the time in seconds), we now save the expiry timestamp for every response we receive. A "cleanup" go routine then goes through our cache every 10s and removes entries that have expired.
@Stebalien, could you review this PR?