mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
31 lines
771 B
PowerShell
31 lines
771 B
PowerShell
|
|
function Get-IcingaCacheData()
|
||
|
|
{
|
||
|
|
param(
|
||
|
|
[string]$Space,
|
||
|
|
[string]$CacheStore,
|
||
|
|
[string]$KeyName
|
||
|
|
);
|
||
|
|
|
||
|
|
$CacheFile = Join-Path -Path (Join-Path -Path (Join-Path -Path (Get-IcingaCacheDir) -ChildPath $Space) -ChildPath $CacheStore) -ChildPath ([string]::Format('{0}.json', $KeyName));
|
||
|
|
[string]$Content = '';
|
||
|
|
$cacheData = @{};
|
||
|
|
|
||
|
|
if ((Test-Path $CacheFile) -eq $FALSE) {
|
||
|
|
return $null;
|
||
|
|
}
|
||
|
|
|
||
|
|
$Content = Get-Content -Path $CacheFile;
|
||
|
|
|
||
|
|
if ([string]::IsNullOrEmpty($Content)) {
|
||
|
|
return $null;
|
||
|
|
}
|
||
|
|
|
||
|
|
$cacheData = ConvertFrom-Json -InputObject ([string]$Content);
|
||
|
|
|
||
|
|
if ([string]::IsNullOrEmpty($KeyName)) {
|
||
|
|
return $cacheData;
|
||
|
|
} else {
|
||
|
|
return $cacheData.$KeyName;
|
||
|
|
}
|
||
|
|
}
|