All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Fields | Private Attributes | Related Functions
aerospike Struct Reference

Detailed Description

An instance of aerospike is required to connect to and execute operations against an Aerospike Database cluster.

Configuration

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:

as_config_init(&config);
config.hosts[0] = { "127.0.0.1", 3000 };

A single host is used to specify a host in the database cluster to connect to. Once connected to a host in the cluster, then client will gather information about the cluster, including all the other nodes in the cluster. So, all that is needed is a single valid host, because once a single host is connected, the then no other hosts in the configuration will be processed.

Initialization

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:

Both initialization functions require a configuration.

The following uses a stack allocated aerospike and initializes it with aerospike_init():

aerospike_init(&as, &config);

Connecting

An application can connect to the database with an initialized aerospike. At this point, the client has not connected. 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);
}

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.

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);

Destruction

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

Definition at line 158 of file aerospike.h.

#include "aerospike.h"

+ Collaboration diagram for aerospike:

Data Fields

as_config config
 

Private Attributes

bool _free
 
struct as_cluster_s * cluster
 

Related Functions

(Note that these are not member functions.)

as_status aerospike_close (aerospike *as, as_error *err)
 
as_status aerospike_connect (aerospike *as, as_error *err)
 
void aerospike_destroy (aerospike *as)
 
aerospikeaerospike_init (aerospike *as, as_config *config)
 
aerospikeaerospike_new (as_config *config)
 

Friends And Related Function Documentation

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.
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.
void aerospike_destroy ( aerospike as)
related

Destroy the aerospike instance and associated resources.

Parameters
asThe aerospike instance to destroy
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.

aerospike_init(&as, &config);

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 * aerospike_new ( as_config config)
related

Creates a new heap allocated aerospike instance.

aerospike * as = aerospike_new(&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.

Field Documentation

bool aerospike::_free
private

If true, then as_query_destroy() will free this instance.

Definition at line 164 of file aerospike.h.

struct as_cluster_s* aerospike::cluster
private

Cluster state.

Definition at line 170 of file aerospike.h.

as_config aerospike::config

client configuration

Definition at line 175 of file aerospike.h.


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