Improve performance of ContainerRegistry repositories by caching token #1920
+14
−1
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.
PR Summary
This pull request introduces caching for container registry access tokens in the
ContainerRegistryServerAPICallsclass to avoid unnecessary repeated retrievals. The main changes focus on improving performance and reducing redundant network calls by storing and reusing the access token during the object's lifetime.Container registry access token caching:
_cachedContainterRegistryTokento store the access token for reuse.nullin the constructor to ensure a fresh start for each instance.GetContainerRegistryAccessTokento check for and return the cached token if available, logging a verbose message when the cache is used.PR Context
In local testing, the improvement in performance for find with wildcard improved by 88% and install with dependencies improved by 83%
NOTE: We create a new instance of
ContainerRegistryServerAPICallsfor each invocation of any cmdlet. The cache is only shared within a single cmdlet invocation.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.