> 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/es/comandos-de-powershell/set-psucache.md).

# Set-PSUCache

Set-PSUCache almacena un objeto en la caché del lado del servidor de PowerShell Universal, con expiración, persistencia y acceso por roles configurables.

## SINOPSIS

Coloca un objeto en la caché global del servidor.

## SINTAXIS

```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` es un alias de `-ReaderRole`.

## DESCRIPCIÓN

Serializa un valor en CLIXML y lo almacena en la caché global del servidor compartida por las APIs, las aplicaciones y los scripts; este comando también funciona a través de la API de administración. Elija una forma de expiración u omítala para almacenar en caché sin una expiración configurada. Utilice `-Persist` para el almacenamiento en la base de datos. `-Encrypt` requiere `-Persist`; usarlo sin persistencia produce un error.

## EJEMPLOS

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

El segundo ejemplo expira en diez minutos, el tercero expira treinta minutos después de la creación y el cuarto expira diez minutos después de su último acceso.

## PARÁMETROS

| Parámetro                    | Descripción                                                                           |
| ---------------------------- | ------------------------------------------------------------------------------------- |
| `-Key`                       | Clave de caché obligatoria.                                                           |
| `-Value`                     | Objeto obligatorio, serializado en CLIXML.                                            |
| `-AbsoluteExpiration`        | Fecha y hora de expiración fijas.                                                     |
| `-AbsoluteExpirationFromNow` | Duración desde ahora hasta la expiración.                                             |
| `-SlidingExpiration`         | Duración de inactividad antes de la expiración; el acceso restablece el temporizador. |
| `-Persist`                   | Conserva el elemento de caché en la base de datos.                                    |
| `-Encrypt`                   | Cifra el elemento conservado; requiere `-Persist`.                                    |
| `-ReaderRole`                | Roles con permiso para leer el elemento (alias `-Role`).                              |
| `-Depth`                     | Profundidad de serialización (1 de forma predeterminada).                             |
| `-ComputerName`              | URL o nombre de host del servidor PSU de destino (alias `-Uri`).                      |
| `-AppToken`                  | Token de aplicación de la API de administración.                                      |
| `-Credential`                | Credenciales de la API de administración.                                             |
| `-UseDefaultCredentials`     | Usa las credenciales actuales de Windows.                                             |
| `-Integrated`                | Usa el cliente de administración en proceso.                                          |
| `-TrustCertificate`          | Ignora los errores de validación del certificado.                                     |
| `-Cookies`                   | Reutiliza las cookies de autenticación de la sesión.                                  |

## ENLACES RELACIONADOS

[Get-PSUCache](/powershell-universal/es/comandos-de-powershell/get-psucache.md)

## PERMISOS

El token de acceso requiere `platform.cache/create` para establecer un valor de caché de forma remota, incluso al reemplazar un valor existente.


---

# 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/es/comandos-de-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.
