Loading...
Searching...
No Matches
Data Fields | Private Attributes | Related Symbols
aerospike Struct Reference

Detailed Description

The aerospike struct is used to connect and execute operations against an Aerospike database cluster.

Configuration

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.

as_config_init(&config);
as_config_add_host(&config, "127.0.0.1", 3000);
as_config config
Definition aerospike.h:177

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

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():

AS_EXTERN aerospike * aerospike_init(aerospike *as, as_config *config)

Connecting

The client will be connected if aerospike_connect() completes successfully:

if (aerospike_connect(&as, &err) != AEROSPIKE_OK) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
@ AEROSPIKE_OK
Definition as_status.h:128
AS_EXTERN as_status aerospike_connect(aerospike *as, as_error *err)

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.

Disconnecting

When the connection to the database is not longer required, then the connection to the cluster can be closed via aerospike_close():

aerospike_close(&as, &err);
AS_EXTERN as_status aerospike_close(aerospike *as, as_error *err)

Destruction

When the client is not longer required, the client and its resources should be releases via aerospike_destroy():

AS_EXTERN void aerospike_destroy(aerospike *as)

Definition at line 166 of file aerospike.h.

#include "aerospike.h"

+ Collaboration diagram for aerospike:

Data Fields

as_config config
 

Private Attributes

struct as_cluster_s * cluster
 

Related Symbols

(Note that these are not member symbols.)

AS_EXTERN as_status aerospike_close (aerospike *as, as_error *err)
 
AS_EXTERN bool aerospike_cluster_is_connected (aerospike *as)
 
AS_EXTERN as_status aerospike_connect (aerospike *as, as_error *err)
 
AS_EXTERN void aerospike_destroy (aerospike *as)
 
AS_EXTERN aerospikeaerospike_init (aerospike *as, as_config *config)
 
AS_EXTERN void aerospike_init_lua (as_config_lua *config)
 
AS_EXTERN aerospikeaerospike_new (as_config *config)
 
AS_EXTERN as_status aerospike_reload_tls_config (aerospike *as, as_error *err)
 
AS_EXTERN as_status aerospike_set_xdr_filter (aerospike *as, as_error *err, as_policy_info *policy, const char *dc, const char *ns, const char *filter_b64)
 
AS_EXTERN void aerospike_stop_on_interrupt (bool stop)
 
AS_EXTERN as_status aerospike_truncate (aerospike *as, as_error *err, as_policy_info *policy, const char *ns, const char *set, uint64_t before_nanos)
 

Friends And Related Symbol Documentation

◆ aerospike_close()

AS_EXTERN as_status aerospike_close ( aerospike * as,
as_error * err )
related

Close connections to the cluster.

aerospike_close(&as, &err);
Parameters
asThe aerospike instance to disconnect from a cluster.
errIf an error occurs, the err will be populated.
Returns
AEROSPIKE_OK on success. Otherwise an error occurred.

◆ aerospike_cluster_is_connected()

AS_EXTERN bool aerospike_cluster_is_connected ( aerospike * as)
related

Is cluster connected to any server nodes.

bool connected = aerospike_cluster_is_connected(&as);
AS_EXTERN bool aerospike_cluster_is_connected(aerospike *as)
Parameters
asThe aerospike instance to check.
Returns
true when cluster is connected.

◆ aerospike_connect()

AS_EXTERN as_status aerospike_connect ( aerospike * as,
as_error * err )
related

Connect an aerospike instance to the cluster.

aerospike_connect(&as, &err);

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().

Parameters
asThe aerospike instance to connect to a cluster.
errIf an error occurs, the err will be populated.
Returns
AEROSPIKE_OK on success. Otherwise an error occurred.

◆ aerospike_destroy()

AS_EXTERN void aerospike_destroy ( aerospike * as)
related

Destroy the aerospike instance and associated resources.

Parameters
asThe aerospike instance to destroy

◆ aerospike_init()

AS_EXTERN aerospike * aerospike_init ( aerospike * as,
as_config * config )
related

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.

Parameters
asThe aerospike instance to initialize.
configThe configuration to use for the instance.
Returns
the initialized aerospike instance
See also
config for information on configuring the client.

◆ aerospike_init_lua()

AS_EXTERN void aerospike_init_lua ( as_config_lua * config)
related

Initialize global lua configuration.

Parameters
configThe lua configuration to use for all cluster instances.

◆ aerospike_new()

AS_EXTERN aerospike * aerospike_new ( as_config * config)
related

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.

AS_EXTERN aerospike * aerospike_new(as_config *config)

Once you are finished using the instance, then you should destroy it via the aerospike_destroy() function.

Parameters
configThe configuration to use for the instance.
Returns
a new aerospike instance
See also
config for information on configuring the client.

◆ aerospike_reload_tls_config()

AS_EXTERN as_status aerospike_reload_tls_config ( aerospike * as,
as_error * err )
related

Refresh the current TLS configuration by reloading its certificate, key, and blacklist files.

Parameters
asAerospike instance whose TLS configuration to refresh.
errIf an error occurs, this will be populated.
Returns
AEROSPIKE_OK on success. Otherwise an error occurred.

◆ aerospike_set_xdr_filter()

AS_EXTERN as_status aerospike_set_xdr_filter ( aerospike * as,
as_error * err,
as_policy_info * policy,
const char * dc,
const char * ns,
const char * filter_b64 )
related

Set XDR filter for given datacenter name and namespace. The expression filter indicates which records XDR should ship to the datacenter.

Parameters
asAerospike instance.
errIf an error occurs, this will be populated.
policyInfo policy. If NULL, then the default policy will be used.
dcDatacenter name.
nsNamespace.
filter_b64expression filter in base64 encoding. Use as_exp_build_b64() to create.
Returns
AEROSPIKE_OK on success. Otherwise an error occurred.

◆ aerospike_stop_on_interrupt()

AS_EXTERN void aerospike_stop_on_interrupt ( bool stop)
related

Should stop socket operation if interrupted by a signal. Default is false which means the socket operation will be retried until timeout.

◆ aerospike_truncate()

AS_EXTERN as_status aerospike_truncate ( aerospike * as,
as_error * err,
as_policy_info * policy,
const char * ns,
const char * set,
uint64_t before_nanos )
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).

Parameters
asAerospike instance.
errIf an error occurs, the err will be populated.
policyInfo policy. If NULL, then the default policy will be used.
nsRequired namespace.
setOptional set name. Pass in NULL to delete all sets in namespace.
before_nanosOptionally 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.
Returns
AEROSPIKE_OK on success. Otherwise an error occurred.

Field Documentation

◆ cluster

struct as_cluster_s* aerospike::cluster
private

Cluster state.

Definition at line 172 of file aerospike.h.

◆ config

as_config aerospike::config

Client configuration.

Definition at line 177 of file aerospike.h.


The documentation for this struct was generated from the following file: