Skip to main content

Refresh-ZrItem

Restarts an item's TTL countdown by re-writing it with its existing time-to-live. Requires that the item currently has a TTL.

Syntax

Refresh-ZrItem [-Key] <string> [-ConnectionString <string>] [-StoreName <string>] [-Endpoints <string[]>] [-TimeoutSec <int>]

Description

Refresh-ZrItem extends the lifetime of an expiring item. It reads the current value and remaining TTL of -Key, then writes the value back with the same TTL (Put.WithTtl), which resets the expiry countdown to the full original duration — a sliding-expiration / keep-alive pattern.

The command reports a failure (Success = false) without raising an error in two cases: the key does not exist (Error = "Key does not exist"), or the item has no TTL to refresh (Error = "Item has no TTL to refresh"). To assign a different TTL rather than reuse the existing one, use Set-ZrItemExpiration.md.

The command runs against the active Connect-ZrStore session, or against a one-shot connection when -StoreName and -Endpoints are supplied.

Parameters

ParameterTypeRequiredDescription
-KeyStringYesKey identifying the item whose TTL should be refreshed. Positional (position 0). Must not be null or empty.
-ConnectionStringStringNoConnect via a Zaris connection string, e.g. zaris://host:7861/store; an alternative to -StoreName + -Endpoints for a one-shot connection. Ignored when a Connect-ZrStore session is active.
-StoreNameStringNoStore to target when using an independent (one-shot) connection instead of the active session. Requires -Endpoints.
-EndpointsString[]NoOne or more node endpoints (host:port) for an independent connection. Ignored when a Connect-ZrStore session is active.
-TimeoutSecInt32NoConnection timeout in seconds (1–120) for an independent connection. Default 5.

Examples

Restart the expiry countdown of a session item using its existing TTL:

Refresh-ZrItem -Key "session:user123"

Refresh a cached object over a one-shot connection:

Refresh-ZrItem -Key "cache:product:100" -ConnectionString "zaris://10.0.0.5:7861/web"