![]() |
An instance of aerospike is required to connect to and execute operations against an Aerospike Database cluster.
An initialized client configuration is required to initialize a aerospike client. See as_config for details on configuration options.
At a minimum, a configuration needs to be initialized and have at least one host 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.
An initialized aerospike object is required to connect to the database. Initialization requires a configuration to bind to the client instance.
The aerospike object can be initialized via either:
- aerospike_init() — Initialize a stack allocated @ref aerospike.
Both initialization functions require a configuration. Once initialized, the ownership of the as_config instance fields are transferred to aerospike. The user should never call as_config_destroy() directly.
The following uses a stack allocated aerospike and initializes it with aerospike_init():
An application can connect to the database with an initialized aerospike. The client will be connected if aerospike_connect()
completes successfully:
The err
parameter will be populated if an error while attempting to connect to the database. 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 180 of file aerospike.h.
#include "aerospike.h"
Data Fields | |
as_config | config |
Private Attributes | |
struct as_cluster_s * | cluster |
Related Functions | |
(Note that these are not member functions.) | |
as_status | aerospike_close (aerospike *as, as_error *err) |
bool | aerospike_cluster_is_connected (aerospike *as) |
as_status | aerospike_connect (aerospike *as, as_error *err) |
void | aerospike_destroy (aerospike *as) |
bool | aerospike_has_pipelining (aerospike *as) |
aerospike * | aerospike_init (aerospike *as, as_config *config) |
aerospike * | aerospike_new (as_config *config) |
as_status | aerospike_reload_tls_config (aerospike *as, as_error *err) |
void | aerospike_stop_on_interrupt (bool stop) |
as_status | aerospike_truncate (aerospike *as, as_error *err, as_policy_info *policy, const char *ns, const char *set, uint64_t before_nanos) |
Close connections to the cluster.
as | The aerospike instance to disconnect from a cluster. |
err | If an error occurs, the err will be populated. |
|
related |
Is cluster connected to any server nodes.
as | The aerospike instance to check. |
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. |
|
related |
Destroy the aerospike instance and associated resources.
as | The aerospike instance to destroy |
|
related |
Do all server nodes in the cluster support async pipelining.
as | The aerospike instance to check. |
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 aerospike. 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. |
Creates a new heap allocated aerospike instance.
Ownership of the as_config instance fields are transferred to aerospike. 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 |
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. Works with Aerospike Server versions >= 3.12.
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 | The policy to use for this operation. 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. |
|
private |
Cluster state.
Definition at line 192 of file aerospike.h.
as_config aerospike::config |
Client configuration.
Definition at line 197 of file aerospike.h.