@@ -134,9 +134,19 @@ function Set-CompletionPrivateData
134134 $Key ,
135135
136136 [object ]
137- $Value )
137+ $Value ,
138138
139- $completionPrivateData [$key ] = $value
139+ [ValidateNotNullOrEmpty ()]
140+ [int ]
141+ $ExpirationSeconds = 20
142+ )
143+
144+ $Cache = [PSCustomObject ]@ {
145+ Value = $Value ;
146+ ExpirationTime = (Get-Date ).AddSeconds($ExpirationSeconds );
147+ };
148+ Add-Content - Path TabExpansion.log - Value (' Setting cache expiration time to: {0}. Key is: {1}' -f $Cache.ExpirationTime , $Key );
149+ $completionPrivateData [$key ] = $Cache ;
140150}
141151
142152# ############################################################################
@@ -148,8 +158,12 @@ function Get-CompletionPrivateData
148158 [string ]
149159 $Key )
150160
151- Flush- BackgroundResultsQueue
152- return $completionPrivateData [$key ]
161+ Flush- BackgroundResultsQueue;
162+
163+ $cacheValue = $completionPrivateData [$key ];
164+ if ((Get-Date ) -lt $cacheValue.ExpirationTime ) {
165+ return $cacheValue.Value ;
166+ }
153167}
154168
155169# ############################################################################
@@ -562,7 +576,15 @@ function Update-ArgumentCompleter
562576# ############################################################################
563577#
564578# . SYNOPSIS
579+ # Retrieves a list of argument completers that have been loaded into the
580+ # PowerShell session.
581+ #
582+ # . PARAMETER Name
583+ # The name of the argument complete to retrieve. This parameter supports
584+ # wildcards (asterisk).
565585#
586+ # . EXAMPLE
587+ # Get-ArgumentComplete
566588function Get-ArgumentCompleter
567589{
568590 [CmdletBinding ()]
@@ -796,7 +818,7 @@ function Flush-BackgroundResultsQueue
796818 $parameters = $item.Value
797819 if ($item.ArgumentCompleter )
798820 {
799- Register-ArgumentCompleter @parameters
821+ TabExpansion ++ \ Register-ArgumentCompleter @parameters
800822 }
801823 elseif ($item.InitializationData )
802824 {
0 commit comments