Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Add global parsed index cache (#132)
Browse files Browse the repository at this point in the history
This dedupes parsing the index (and the index itself) so we aren't
parsing the same index over and over again (and holding a bunch of
copies in memory).

Again, not the best, but this is the second of three things we're going
to dedupe in-process like this, mostly for the terraform provider, which
does a lot of simultaneous work that is very very similar and amenable
to this kind of deduplication.

Signed-off-by: Jon Johnson <[email protected]>
  • Loading branch information
jonjohnsonjr authored Oct 10, 2023
1 parent 49b8212 commit 5e3480e
Show file tree
Hide file tree
Showing 3 changed files with 217 additions and 157 deletions.
4 changes: 2 additions & 2 deletions pkg/apk/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
// This is terrible but simpler than plumbing around a cache for now.
// We will assume that for a given process, we want to reuse etag values.
// Doing this cuts down on the number of requests we send for index and keys.
var globalCache = &etagCache{}
var globalEtagCache = &etagCache{}

type etagResp struct {
resp *http.Response
Expand Down Expand Up @@ -225,7 +225,7 @@ func (t *cacheTransport) RoundTrip(request *http.Request) (*http.Response, error
}, nil
}

return globalCache.get(t, request, cacheFile)
return globalEtagCache.get(t, request, cacheFile)
}

func cacheDirFromFile(cacheFile string) string {
Expand Down
Loading

0 comments on commit 5e3480e

Please sign in to comment.