Skip to content

Commit be1435c

Browse files
committed
Add registration index cache.
1 parent ccce140 commit be1435c

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

ModuleFast.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ function Get-ModuleFastPlan {
182182
#TODO: Capture this somewhere that we can use it to report in the deploy plan
183183
continue
184184
}
185+
185186
$task = Get-ModuleInfoAsync @httpContext -Endpoint $Source -Name $moduleSpec.Name
186187
$resolveTasks[$task] = $moduleSpec
187188
$currentTasks.Add($task)
@@ -1046,7 +1047,12 @@ function Get-ModuleInfoAsync {
10461047

10471048
#This call should be cached by httpclient after first attempt to speed up future calls
10481049
#TODO: Only select supported versions
1049-
$registrationBase = $HttpClient.GetStringAsync($Endpoint, $CancellationToken).GetAwaiter().GetResult()
1050+
#TODO: Cache this index more centrally to be used for other services
1051+
if (-not $SCRIPT:__registrationIndex) {
1052+
$SCRIPT:__registrationIndex = $HttpClient.GetStringAsync($Endpoint, $CancellationToken).GetAwaiter().GetResult()
1053+
}
1054+
1055+
$SCRIPT:__registrationIndex
10501056
| ConvertFrom-Json
10511057
| Select-Object -ExpandProperty Resources
10521058
| Where-Object {
@@ -1060,6 +1066,7 @@ function Get-ModuleInfoAsync {
10601066

10611067
#TODO: System.Text.JSON serialize this with fancy generic methods in 7.3?
10621068
Write-Debug ('{0}fetch info from {1}' -f ($ModuleId ? "$ModuleId`: " : ''), $uri)
1069+
10631070
return $HttpClient.GetStringAsync($uri, $CancellationToken)
10641071
}
10651072

0 commit comments

Comments
 (0)