This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Connecting
Mira Dytko edited this page Jan 13, 2022
·
2 revisions
This describes the preferred Aerospike PHP client connection methods.
The Aerospike PHP client is cluster-aware. The client learns cluster topology from any node connection and tracks cluster status.
The Aerospike PHP client automatically shards data. See Data Distribution.
The Aerospike class constructor configuration must follow the format:
-
hosts
— A host data array. -
addr
— Node hostname or IP. port
$config = [
"hosts" => [
["addr" => "127.0.0.1", "port" => 3000]
]
];
The constructor uses the configuration to initialize the cluster connection.
$db = new Aerospike($config);
To verify the connection using isConnected():
if (!$db->isConnected()) {
echo "Failed to connect to the Aerospike server [{$db->errorno()}]: {$db->error()}\n";
exit(1);
}
On successful connection, the client is ready for your application to perform database operations.
PHP Client