The Cache provider is Universal specific. You should be able to use cmdlets like Remove-Item to clear out specific variables. You can also access the cache dictionary directly to clear the entire thing.
If you want to clear out a specific variable, you can just set it to null and it will no longer contain the cached data:
$Cache:Datalist = $null
If you want to completely remove the record from the cache (including the key), you can clear the item from the cache directly. It won’t really save any more memory unless you have millions of items in the cache.
We are still a litte confused by the Cache variable. When we use Cache:datalist and add a number of values to this variable that are used to display on the dashboard, and if we do any restarts of the dashboard in the admin portal, I start seeing duplicate values.
Using $Cache:datalist = $null does not clear the variable per say but makes it null and I get a bunch of these errors
You cannot call a method on a null-valued expression.
When I restart PSU Server (recycle service) then the data is fresh and I only see singular values for different data elements which is correct. when I restart the dashboard a few times in the admin portal I start seeing duplicates.
What I am trying to do is prevent the duplicates that show up when I restart the dashboard a few times without clearing the Cache:datalist.
I am wondering if I need to do something like this (not pure powershell)
if exists (Cache:datalist(data)) {
Cache:datalist.Replace(data)
} else {
Cache:datalist.Add(data)
}
It makes me think that New-UDEndpoint is running more than once when doing restarts. @DataTraveler - Can you open an issue to so that we can investigate this?