Public/ps1/vdb/Set-ApprxrVDBEntry.ps1
|
<#
.SYNOPSIS Sets a VDB entry with key, database name, and TTL. .DESCRIPTION Creates an object with properties: InnerObject (string), Key, DatabaseName, and TTL (default 0). The result is wrapped in an object and passed to Get-ApprxrResult. .PARAMETER InnerObject The string content to store in the entry. .PARAMETER Key The key for the entry. .PARAMETER DatabaseName The database name for the entry. .PARAMETER TTL The time-to-live for the entry (default: 0). .EXAMPLE Set-ApprxrVDBEntry -InnerObject '{"foo":"bar"}' -Key 'mykey' -DatabaseName 'mydb' #> function Set-ApprxrVDBEntry { [CmdletBinding()] param( [Parameter(Mandatory)] $InnerObject, [Parameter(Mandatory)] [string]$Key, [Parameter(Mandatory)] [string]$DatabaseName, [int]$TTL = 0, [switch]$AsJson ) $finalInnerObject = $InnerObject if ($AsJson -and ($null -ne $InnerObject) -and ($InnerObject -is [object]) -and -not ($InnerObject -is [string])) { $finalInnerObject = $InnerObject | ConvertTo-Json -Compress } $entry = [PSCustomObject]@{ InnerObject = $finalInnerObject Key = $Key DatabaseName = $DatabaseName TTL = $TTL } $result = [PSCustomObject]@{ Entry = $entry } Get-ApprxrResult -InputObject $result } |