feat(instances): cache server lookups to reduce API calls#1252
feat(instances): cache server lookups to reduce API calls#1252lukasmetzner wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1252 +/- ##
==========================================
- Coverage 71.01% 67.76% -3.26%
==========================================
Files 24 28 +4
Lines 2677 2835 +158
==========================================
+ Hits 1901 1921 +20
- Misses 604 740 +136
- Partials 172 174 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7e8edf4 to
1d6ef5f
Compare
| subsystem string | ||
| mode Mode | ||
| ttl time.Duration | ||
| expiresAt time.Time |
There was a problem hiding this comment.
I was hoping to have a single cache implementation, where the mode could be picked on the fly (or at least it would be easy to do so).
My idea was that both cache "modes" use a cache entry struct with an expiration date (as it is implement in the per server cache), and decide on the refresh actions to perform based on the mode: if mode is per server, only refresh that server, if the mode is all, refresh all servers.
This would mean with the mode "all", during a refresh iterating over all cache entries to update the expiredAt property.
With this in mind, we could use the same cache for both modes, and even add options in the ByName or ByID methods, to pass e.g. cache.ByName(ctx, "my-server", WithMode("all"), WithExpiration(5 *time.Second))
There was a problem hiding this comment.
I like the idea, I will take a look and explore the implementation detail of it.
Feature is marked as experimental.