![]() |
The aerospike struct is used to connect and execute operations against an Aerospike database cluster.
A client configuration is required to initialize an aerospike client. See as_config for details on configuration options.
At least one seed host must be defined.
Once connected to a host in the cluster, then client will gather information about the cluster, including all other nodes in the cluster. So, all that is needed is a single valid host. Multiple hosts can still be provided in case the first host is not currently active.
Initialization requires a configuration to bind to the client instance.
The aerospike instance can be initialized via either:
Once initialized, the ownership of the as_config instance fields are transferred to the aerospike instance. The user should never call as_config_destroy() directly.
The following uses a stack allocated aerospike instance and initializes it with aerospike_init():
The client will be connected if aerospike_connect()
completes successfully:
The err
parameter will be populated if an error occurs. See as_error for more information on error handling.
An aerospike object internally keeps cluster state and maintains connection pools to the cluster. The same aerospike object should be reused by the application for database operations to a given cluster.
If the application requires connecting to multiple Aerospike clusters, the application must create multiple aerospike objects, each connecting to a different cluster.
When the connection to the database is not longer required, then the connection to the cluster can be closed via aerospike_close()
:
When the client is not longer required, the client and its resources should be releases via aerospike_destroy()
:
Definition at line 166 of file aerospike.h.
#include "aerospike.h"
Data Fields | |
as_config | config |
Private Attributes | |
struct as_cluster_s * | cluster |
|
related |
Abort and rollback the given transaction.
Requires server version 8.0+
as | Aerospike instance. |
err | Error detail structure that is populated if an error occurs. |
txn | Transaction. |
abort_status | Indicates success or the step in the abort process that failed. Pass in NULL to ignore. |
|
related |
Asynchronously abort and rollback the given transaction.
Requires server version 8.0+
as | Aerospike instance. |
err | Error detail structure that is populated if an error occurs. |
txn | Transaction. |
listener | User function to be called with command results. |
udata | User data that is forwarded from asynchronous command function. |
event_loop | Event loop that this command was executed on. Use this event loop when running nested asynchronous commands when single threaded behavior is desired for the group of commands. |
Close connections to the cluster.
as | The aerospike instance to disconnect from a cluster. |
err | If an error occurs, the err will be populated. |
Is cluster connected to any server nodes.
as | The aerospike instance to check. |
|
related |
Attempt to commit the given transaction. First, the expected record versions are sent to the server nodes for verification. If all nodes return success, the transaction is committed. Otherwise, the transaction is aborted.
Requires server version 8.0+
as | Aerospike instance. |
err | Error detail structure that is populated if an error occurs. |
txn | Transaction. |
commit_status | Indicates success or the step in the commit process that failed. Pass in NULL to ignore. |
|
related |
Asynchronously attempt to commit the given transaction. First, the expected record versions are sent to the server nodes for verification. If all nodes return success, the transaction is committed. Otherwise, the transaction is aborted.
Requires server version 8.0+
as | Aerospike instance. |
err | Error detail structure that is populated if an error occurs. |
txn | Transaction. |
listener | User function to be called with command results. |
udata | User data that is forwarded from asynchronous command function. |
event_loop | Event loop that this command was executed on. Use this event loop when running nested asynchronous commands when single threaded behavior is desired for the group of commands. |
Connect an aerospike instance to the cluster.
Once you are finished using the connection, then you must close it via the aerospike_close()
function.
If connect fails, then you do not need to call aerospike_close()
.
as | The aerospike instance to connect to a cluster. |
err | If an error occurs, the err will be populated. |
Destroy the aerospike instance and associated resources.
as | The aerospike instance to destroy |
Initialize a stack allocated aerospike instance.
The config parameter can be an instance of as_config
or NULL
. If NULL
, then the default configuration will be used.
Ownership of the as_config instance fields are transferred to the aerospike instance. The user should never call as_config_destroy() directly.
Once you are finished using the instance, then you should destroy it via the aerospike_destroy()
function.
as | The aerospike instance to initialize. |
config | The configuration to use for the instance. |
|
related |
Initialize global lua configuration.
config | The lua configuration to use for all cluster instances. |
Creates a new heap allocated aerospike instance.
Ownership of the as_config instance fields are transferred to the aerospike instance. The user should never call as_config_destroy() directly.
Once you are finished using the instance, then you should destroy it via the aerospike_destroy()
function.
config | The configuration to use for the instance. |
Refresh the current TLS configuration by reloading its certificate, key, and blacklist files.
as | Aerospike instance whose TLS configuration to refresh. |
err | If an error occurs, this will be populated. |
|
related |
Set XDR filter for given datacenter name and namespace. The expression filter indicates which records XDR should ship to the datacenter.
as | Aerospike instance. |
err | If an error occurs, this will be populated. |
policy | Info policy. If NULL, then the default policy will be used. |
dc | Datacenter name. |
ns | Namespace. |
filter_b64 | expression filter in base64 encoding. Use as_exp_build_b64() to create. |
|
related |
Should stop socket operation if interrupted by a signal. Default is false which means the socket operation will be retried until timeout.
|
related |
Remove records in specified namespace/set efficiently. This method is many orders of magnitude faster than deleting records one at a time.
See https://www.aerospike.com/docs/reference/info#truncate
This asynchronous server call may return before the truncation is complete. The user can still write new records after the server returns because new records will have last update times greater than the truncate cutoff (set at the time of truncate call).
as | Aerospike instance. |
err | If an error occurs, the err will be populated. |
policy | Info policy. If NULL, then the default policy will be used. |
ns | Required namespace. |
set | Optional set name. Pass in NULL to delete all sets in namespace. |
before_nanos | Optionally delete records before record last update time. Units are in nanoseconds since unix epoch (1970-01-01). If specified, value must be before the current time. Pass in 0 to delete all records in namespace/set regardless of last update time. |
|
related |
Asynchronous commit listener. This function is called once when aerospike_abort_async() completes or an error has occurred.
err | Error structure that is populated if an error occurs. NULL on success. |
status | Status of abort when err is NULL. |
udata | User data that is forwarded from asynchronous command function. |
event_loop | Event loop that this command was executed on. Use this event loop when running nested asynchronous commands when single threaded behavior is desired for the group of commands. |
Definition at line 133 of file aerospike_txn.h.
|
related |
Asynchronous commit listener. This function is called once when aerospike_commit_async() completes or an error has occurred.
err | Error structure that is populated if an error occurs. NULL on success. |
status | Status of commit when err is NULL. |
udata | User data that is forwarded from asynchronous command function. |
event_loop | Event loop that this command was executed on. Use this event loop when running nested asynchronous commands when single threaded behavior is desired for the group of commands. |
Definition at line 86 of file aerospike_txn.h.
|
private |
Cluster state.
Definition at line 172 of file aerospike.h.
as_config aerospike::config |
Client configuration.
Definition at line 177 of file aerospike.h.