-
Notifications
You must be signed in to change notification settings - Fork 1
delete entries from the cache when the TTL expires #6
base: master
Are you sure you want to change the base?
Conversation
a86344a to
216fbdc
Compare
Stebalien
left a comment
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 would have done this slightly differently, but either way works.
| }, nil | ||
| } | ||
|
|
||
| var cleanupFreq = 10 * time.Second |
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.
Nit: can probably be on the order of minutes. But not really an issue any which way.
client.go
Outdated
| sentEntries = make(map[string]*ServiceEntry) | ||
| var entries map[string]*ServiceEntry | ||
| c.sentEntries = make(map[string]*ServiceEntry) | ||
| go c.cleanupSentEntries(ctx) |
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.
nit: consider doing this inline? There's no real reason to have another loop, and it saves us a lock & shared state.
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.
That's more than just a nit. That's a major simplification!
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.
nit == not really necessary but maybe nice to have. But yeah, it's cleaner now.
216fbdc to
3e3e44e
Compare
3e3e44e to
6724681
Compare
6724681 to
72b80e6
Compare
|
Rebased on top of #9, which (among other things) implements a clean shutdown. This fixes the race conditions we encountered earlier with this PR. |
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?