SyncClient¶
- class aerospike_sdk.sync.client.SyncClient[source]¶
Bases:
objectConnect 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-scopedBehavior.- __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 freshClientPolicywithconn_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 explicitClientPolicyto 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 AELwhere()query — clients that never use AEL filters never spin up the thread.max_error_rate (
Optional[int]) – Per-node circuit-breaker threshold (seeaerospike_sdk.aio.client.Client).error_rate_window (
Optional[int]) – Tend iterations until each node’s error counter resets.indexes_monitor (
Optional[IndexesMonitor]) – Optional pre-constructedIndexesMonitorto share across clients (for example anAsyncPool). When supplied, this client uses it but does not own its lifecycle.current_thread_runtime (
bool) – Experimental — opt-in, subject to removal. WhenTrue, each calling OS thread gets its own PAC_LocalClient(sync-only, backed by a per-threadcurrent_threadTokio 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: setpolicy.conn_pools_per_node = 1so 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. TheIndexesMonitordaemon thread is not started here; it lazy-starts on the first AELwhere()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 ownaerospike_async.LocalClienton first op.Idempotent: returns early if already connected.
- Return type:
- close()[source]¶
Close the connection synchronously.
Stops the
IndexesMonitordaemon thread (if owned) and calls PAC’sclose_blocking. Safe to call when already closed.- Return type:
- 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. ReturnsSyncQueryBuilderwhose.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:
- 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: