refactor: abstract versioned cache#483
Merged
Merged
Conversation
80d5d80 to
535de54
Compare
smira
reviewed
Jun 15, 2026
| // Failed fetches are not cached. | ||
| type VersionedCache[T any] struct { | ||
| fetch func(tag string) ([]T, error) | ||
| entries map[string][]T |
Member
There was a problem hiding this comment.
in order to make it more generic, I would replace []T here with T, as nothing in this code relies on it being a slice actually.
On error, return zero value of T (var zero T) instead of nil.
This would make this code work with any T type.
smira
reviewed
Jun 15, 2026
| // Fetches are de-duplicated across concurrent callers via an internal | ||
| // singleflight group, and respect the caller's context for cancellation. | ||
| // Failed fetches are not cached. | ||
| type VersionedCache[T any] struct { |
Member
There was a problem hiding this comment.
Probably something like SingleflightCache (as it's not really versioned in any way). It's rather unbounded cache with singleflight protection?
535de54 to
8fcb52d
Compare
smira
reviewed
Jun 15, 2026
smira
reviewed
Jun 15, 2026
smira
reviewed
Jun 15, 2026
smira
reviewed
Jun 15, 2026
smira
approved these changes
Jun 15, 2026
8fcb52d to
d493e77
Compare
I didn't wan't to duplicate the code a fourth time for the extra extensions so here's a little abstraction Signed-off-by: Orzelius <33936483+Orzelius@users.noreply.github.com>
d493e77 to
e0e4a44
Compare
Member
Author
|
/m |
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.
I didn't wan't to duplicate the code a fourth time for the extra extensions so here's a little abstraction