> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/da/powershell-kommandoer/set-psucache.md).

# Set-PSUCache

Set-PSUCache gemmer et objekt i cachen på serversiden i PowerShell Universal med konfigurerbart udløb, persistens og rolleadgang.

## Synopsis

Sætter et objekt i den serverdækkende cache.

## Syntaks

```powershell
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` er et alias for `-ReaderRole`.

## Beskrivelse

Serialiserer en værdi til CLIXML og gemmer den i den serveromfattende cache, der deles af API'er, apps og scripts; denne kommando fungerer også via administrations-API'en. Vælg én udløbsform, eller udelad én for at cache uden et konfigureret udløb. Brug `-Persist` til databaseunderstøttet lager. `-Encrypt` kræver `-Persist`; brug af den uden persistens medfører en fejl.

## Eksempler

```powershell
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 -Encrypt
```

Det andet eksempel udløber om ti minutter, det tredje udløber tredive minutter efter oprettelsen, og det fjerde udløber ti minutter efter sin seneste adgang.

## Parametre

| Parameter                    | Beskrivelse                                                   |
| ---------------------------- | ------------------------------------------------------------- |
| `-Key`                       | Påkrævet cachenøgle.                                          |
| `-Value`                     | Påkrævet objekt, serialiseret til CLIXML.                     |
| `-AbsoluteExpiration`        | Fast udløbsdato og -klokkeslæt.                               |
| `-AbsoluteExpirationFromNow` | Varighed fra nu indtil udløb.                                 |
| `-SlidingExpiration`         | Varighed af inaktivitet før udløb; adgang nulstiller timeren. |
| `-Persist`                   | Bevarer cacheelementet i databasen.                           |
| `-Encrypt`                   | Krypterer det lagrede element; kræver `-Persist`.             |
| `-ReaderRole`                | Roller med tilladelse til at læse elementet (alias `-Role`).  |
| `-Depth`                     | Serialiseringsdybde (standard 1).                             |
| `-ComputerName`              | URL eller værtsnavn for PSU-målserveren (alias `-Uri`).       |
| `-AppToken`                  | App-token til Management API.                                 |
| `-Credential`                | Legitimationsoplysninger til Management API.                  |
| `-UseDefaultCredentials`     | Bruger de aktuelle Windows-legitimationsoplysninger.          |
| `-Integrated`                | Bruger den integrerede administrationsklient i processen.     |
| `-TrustCertificate`          | Ignorerer fejl ved certifikatvalidering.                      |
| `-Cookies`                   | Genbruger sessionscookies til godkendelse.                    |

## Relaterede links

[Get-PSUCache](/powershell-universal/da/powershell-kommandoer/get-psucache.md)

## Tilladelser

Adgangstokenet kræver `platform.cache/create` for at angive en cacheværdi eksternt, herunder når en eksisterende værdi erstattes.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/da/powershell-kommandoer/set-psucache.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
