Skip to main content

Test-ZrItem

Tests whether an item exists in the Zaris store, returning a boolean by default or a detailed result object with -Detailed.

Syntax

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

Description

Test-ZrItem checks for the presence of the item stored under the given key on the connected Zaris store using a lightweight, non-mutating get. By default it returns $true or $false; with -Detailed it returns an object describing the check. Use it in conditional automation, cache checks, or coordination-key validation.

The cmdlet requires an active connection (Connect-ZrStore) or a one-shot independent connection supplied through -StoreName and -Endpoints.

Parameters

ParameterTypeRequiredDescription
-KeyStringYesThe key whose existence is tested. Positional (position 0). Must not be null or empty.
-DetailedSwitchParameterNoReturn a detailed result object instead of a plain boolean.
-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 operate on for a one-shot independent connection instead of the active Connect-ZrStore context. Belongs to the Independent parameter set; use together with -Endpoints.
-EndpointsString[]NoOne or more store node endpoints (host:port) for an independent connection. Only the first endpoint is used as the seed. Ignored when a Connect-ZrStore session is active.
-TimeoutSecInt32NoConnection timeout, in seconds, for an independent connection. Range 1–120. Default 5.

By default returns a Boolean. With -Detailed, returns an object with StoreName, Key, Exists, Success, and Error.

Examples

Return $true if an item exists under the key, otherwise $false:

Test-ZrItem -Key "session:abc123"

Get a structured result for use in a script:

Test-ZrItem -Key "session:abc123" -Detailed

Branch on existence:

if (Test-ZrItem -Key "leader") { "leader present" } else { "no leader" }