SyncClient

class aerospike_sdk.sync.client.SyncClient[source]

Bases: object

Connect to Aerospike and run the SDK API without async/await.

Example:

with SyncClient("localhost:3000") as client:
    for row in client.query(
        namespace="test",
        set_name="users"
    ).execute():
        if row.record:
            print(row.record.bins)

See also

Client: Async equivalent. create_session(): Session-scoped Behavior.

__init__(seeds, policy=None, index_refresh_interval=5.0, *, max_error_rate=None, error_rate_window=None, indexes_monitor=None, current_thread_runtime=False)[source]

Initialize a SyncClient (no IO).

Parameters:
  • seeds (str) – Aerospike cluster seed addresses (e.g., “localhost:3000”).

  • policy (Optional[ClientPolicy]) – Optional client policy. When not supplied, defaults to a fresh ClientPolicy with conn_pools_per_node = 8 (PAC’s default of 4 is tuned for async; sync workloads driven from many caller threads see real connection-pool mutex contention at 4). Pass an explicit ClientPolicy to override either this default or any other client-level setting.

  • index_refresh_interval (float) – Seconds between secondary index cache refreshes (default 5.0). The monitor is a daemon thread that starts lazily on the first AEL where() query — clients that never use AEL filters never spin up the thread.

  • max_error_rate (Optional[int]) – Per-node circuit-breaker threshold (see aerospike_sdk.aio.client.Client).

  • error_rate_window (Optional[int]) – Tend iterations until each node’s error counter resets.

  • indexes_monitor (Optional[IndexesMonitor]) – Optional pre-constructed IndexesMonitor to share across clients (for example an AsyncPool). When supplied, this client uses it but does not own its lifecycle.

  • current_thread_runtime (bool) – Experimental — opt-in, subject to removal. When True, each calling OS thread gets its own PAC _LocalClient (sync-only, backed by a per-thread current_thread Tokio runtime). Eliminates the cross-thread worker hop on every op for ~+30-40% TPS lift on 32-thread sync workloads. Open caveat before production use: per-thread cluster tend multiplies info load on the cluster at high thread counts. Recommended pairing when opted in: set policy.conn_pools_per_node = 1 so total connections per node stay modest (N threads × 1 ≈ shared client’s 8).

connect()[source]

Open a connection to the cluster synchronously.

Calls aerospike_async.new_client_blocking() directly — no asyncio loop is constructed. The IndexesMonitor daemon thread is not started here; it lazy-starts on the first AEL where() query.

When current_thread_runtime=True, no PAC Client is constructed here. Instead a thread-local proxy is installed; each calling OS thread lazy-constructs its own aerospike_async.LocalClient on first op.

Idempotent: returns early if already connected.

Return type:

None

close()[source]

Close the connection synchronously.

Stops the IndexesMonitor daemon thread (if owned) and calls PAC’s close_blocking. Safe to call when already closed.

Return type:

None

property is_connected: bool

True once connect() has succeeded and close() hasn’t run.

property underlying_client: Client

The underlying PAC aerospike_async.Client.

Use for PAC calls the SDK doesn’t wrap (info, nodes, etc.).

query(arg1=None, set_name=None, namespace=None, *, dataset=None, key=None, keys=None, behavior=None, namespace_mode_resolver=None, namespace_mode_resolver_blocking=None)[source]
Overloads:
  • self, arg1 (DataSet), behavior (Optional[Behavior]) → SyncQueryBuilder

  • self, arg1 (Key), behavior (Optional[Behavior]) → SyncQueryBuilder

  • self, arg1 (List[Key]), behavior (Optional[Behavior]) → SyncQueryBuilder

  • self, arg1 (str), set_name (str), behavior (Optional[Behavior]) → SyncQueryBuilder

Create a synchronous query builder.

Same calling shapes as Client.query. Returns SyncQueryBuilder whose .execute() runs synchronously.

index(namespace=None, set_name=None, *, dataset=None, behavior=None)[source]
Overloads:
  • self, dataset (DataSet), behavior (Optional[Behavior]) → SyncIndexBuilder

  • self, namespace (str), set_name (str), behavior (Optional[Behavior]) → SyncIndexBuilder

Create a secondary-index builder (synchronous).

truncate(dataset, before_nanos=None)[source]

Truncate a set, synchronously (PAC truncate_blocking).

Return type:

None

register_udf(body, server_path, language=UDFLang.LUA, *, policy=None)[source]

Register a UDF module from bytes (synchronous).

Return type:

RegisterTask

register_udf_from_file(client_path, server_path, language=UDFLang.LUA, *, policy=None)[source]

Register a UDF module from a local file (synchronous).

Return type:

RegisterTask

remove_udf(server_path, *, policy=None)[source]

Remove a UDF module from the cluster (synchronous).

Return type:

UdfRemoveTask

create_session(behavior=None)[source]

Create a synchronous session with the specified behavior.

Return type:

SyncSession

create_transactional_session(behavior=None)[source]

Create a synchronous multi-record transaction session.

Return type:

SyncTransactionalSession