> 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/it/comandi-powershell/set-psucache.md).

# Set-PSUCache

Set-PSUCache archivia un oggetto nella cache lato server di PowerShell Universal, con scadenza, persistenza e accesso ai ruoli configurabili.

## SINOSSI

Inserisce un oggetto nella cache a livello di server.

## SINTASSI

```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` è un alias di `-ReaderRole`.

## DESCRIZIONE

Serializza un valore in CLIXML e lo archivia nella cache a livello di server condivisa da API, app e script; questo comando funziona anche tramite l'API di gestione. Scelga una forma di scadenza oppure ne ometta una per memorizzare nella cache senza una scadenza configurata. Usi `-Persist` per l'archiviazione nel database. `-Encrypt` richiede `-Persist`; usarlo senza persistenza genera un errore.

## ESEMPI

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

Il secondo esempio scade tra dieci minuti, il terzo scade trenta minuti dopo la creazione e il quarto scade dieci minuti dopo l'ultimo accesso.

## PARAMETRI

| Parametro                    | Descrizione                                                               |
| ---------------------------- | ------------------------------------------------------------------------- |
| `-Key`                       | Chiave di cache obbligatoria.                                             |
| `-Value`                     | Oggetto obbligatorio, serializzato in CLIXML.                             |
| `-AbsoluteExpiration`        | Data e ora di scadenza fisse.                                             |
| `-AbsoluteExpirationFromNow` | Durata da adesso fino alla scadenza.                                      |
| `-SlidingExpiration`         | Durata di inattività prima della scadenza; un accesso reimposta il timer. |
| `-Persist`                   | Rende persistente l'elemento della cache nel database.                    |
| `-Encrypt`                   | Cifra l'elemento reso persistente; richiede `-Persist`.                   |
| `-ReaderRole`                | Ruoli autorizzati a leggere l'elemento (alias `-Role`).                   |
| `-Depth`                     | Profondità di serializzazione (1 per impostazione predefinita).           |
| `-ComputerName`              | URL o nome host del server PSU di destinazione (alias `-Uri`).            |
| `-AppToken`                  | Token dell'app dell'API di gestione.                                      |
| `-Credential`                | Credenziali dell'API di gestione.                                         |
| `-UseDefaultCredentials`     | Usa le credenziali Windows correnti.                                      |
| `-Integrated`                | Usa il client di gestione nel processo.                                   |
| `-TrustCertificate`          | Ignora gli errori di convalida del certificato.                           |
| `-Cookies`                   | Riutilizza i cookie di autenticazione della sessione.                     |

## LINK CORRELATI

[Get-PSUCache](/powershell-universal/it/comandi-powershell/get-psucache.md)

## AUTORIZZAZIONI

Il token di accesso richiede `platform.cache/create` per impostare un valore della cache in remoto, anche quando si sostituisce un valore esistente.


---

# 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/it/comandi-powershell/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.
