I’m trying to use Set-PSUCache ... -SlidingExpiration [TimeSpan]::FromMinutes(10) within one API endpoint, and accessing it with Get-PSUCache from within another API endpoint. However even after waiting 30 minutes, the cached data remains available.
Btw, the documentation for Get-PSUCache does not mention this; but what is the expected behaviour when specifying a value for -Name that does not exist (anymore)?
Will it return $Null, or produce a stopping error?
The latter would allow me to use a Try {...} Catch {...} approach, which is preferable to something like If ([boolean](Get-PSUCache -Name 'Foo')) {...} Else {...}
We likely wouldn’t change that behavior until 3.0 but we could introduce either a switch on Get-PSUCache to cause it to throw or introduce something like Test-PSUCache to check if a key exists.