Skip to main content

Get-ZrCounter

Reads the current value of an atomic distributed counter from the connected Clustron Zaris store.

Syntax

Get-ZrCounter [-Key] <string> [-ConnectionString <string>] [-StoreName <string>] [-Endpoints <string[]>] [-TimeoutSec <int>]

Description

Get-ZrCounter reads the value of the atomic counter stored under -Key via the store's counter API (Counters.GetAsync). Counters are maintained atomically across the cluster and are commonly used for distributed metrics, rate limiting, event counting, and telemetry.

The counter must already exist — created by a prior Set-ZrCounter or Increment-ZrCounter. If it cannot be read, the command reports Success = false with the underlying error rather than terminating. 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 counter to read. 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

Read a counter from the connected store:

Get-ZrCounter -Key "orders:processed"

Read a counter over a one-shot independent connection:

Get-ZrCounter visits -ConnectionString "zaris://10.0.0.5:7861/web"