Set-PSUCache
SYNOPSIS
Sets an object in the server-wide cache.
SYNTAX
Set-PSUCache -Key <String> -Value <Object> [-Persist] [-Encrypt] [-ReaderRole <String[]>] [-Depth <Int32>] [<ConnectionOptions>] [<CommonParameters>]
Set-PSUCache -Key <String> -Value <Object> [-AbsoluteExpiration <DateTime>] [-Persist] [-Encrypt] [-ReaderRole <String[]>] [-Depth <Int32>] [<ConnectionOptions>] [<CommonParameters>]
Set-PSUCache -Key <String> -Value <Object> [-AbsoluteExpirationFromNow <TimeSpan>] [-Persist] [-Encrypt] [-ReaderRole <String[]>] [-Depth <Int32>] [<ConnectionOptions>] [<CommonParameters>]
Set-PSUCache -Key <String> -Value <Object> [-SlidingExpiration <TimeSpan>] [-Persist] [-Encrypt] [-ReaderRole <String[]>] [-Depth <Int32>] [<ConnectionOptions>] [<CommonParameters>]<ConnectionOptions>: [-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>] [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]. -Role is an alias of -ReaderRole.
DESCRIPTION
Serializes a value to CLIXML and stores it in the server-wide cache shared by APIs, apps, and scripts; this command also works through the Management API. Choose one expiration form, or omit one to cache without a configured expiration. Use -Persist for database-backed storage. -Encrypt requires -Persist; using it without persistence raises an error.
EXAMPLES
Set-PSUCache -Key 'Data' -Value 'MyValue'
Set-PSUCache -Key 'Data' -Value 'MyValue' -AbsoluteExpiration (Get-Date).AddMinutes(10)
Set-PSUCache -Key 'Data' -Value 'MyValue' -AbsoluteExpirationFromNow ([TimeSpan]::FromMinutes(30))
Set-PSUCache -Key 'Data' -Value 'MyValue' -SlidingExpiration ([TimeSpan]::FromMinutes(10))
Set-PSUCache -Key 'Data' -Value 'MyValue' -Persist -EncryptThe second example expires in ten minutes, the third expires thirty minutes after creation, and the fourth expires ten minutes after its last access.
PARAMETERS
-Key
Required cache key.
-Value
Required object, serialized to CLIXML.
-AbsoluteExpiration
Fixed expiration date and time.
-AbsoluteExpirationFromNow
Duration from now until expiration.
-SlidingExpiration
Duration of inactivity before expiration; access resets the timer.
-Persist
Persists the cache item to the database.
-Encrypt
Encrypts the persisted item; requires -Persist.
-ReaderRole
Roles allowed to read the item (alias -Role).
-Depth
Serialization depth (default 1).
-ComputerName
Target PSU server URL or host name (alias -Uri).
-AppToken
Management API app token.
-Credential
Management API credentials.
-UseDefaultCredentials
Uses current Windows credentials.
-Integrated
Uses the in-process management client.
-TrustCertificate
Ignores certificate validation errors.
-Cookies
Reuses session authentication cookies.
RELATED LINKS
PERMISSIONS
The access token requires platform.cache/create to set a cache value remotely, including when replacing an existing value.
Last updated
Was this helpful?