Aerospike::reconnect - Reconnect to the Aerospike DB
public Aerospike::reconnect ( void )
Aerospike::reconnect() will reconnect to the Aerospike DB cluster. The Aerospike::isConnected() method can be used to test whether the connection succeded. If a connection error occured the Aerospike::error() and Aerospike::errorno() methods can be used to inspect it.
This method has no parameters.
<?php
$config = ["hosts" => [["addr"=>"localhost", "port"=>3000]], "shm"=>[]];
$client = new Aerospike($config, true);
$client->close();
$client->reconnect();
if (!$client->isConnected()) {
echo "Aerospike failed to connect[{$client->errorno()}]: {$client->error()}\n";
exit(1);
}
echo "We have reconnected to the Aerospike DB\n";
?>
On success we expect to see:
We have reconnected to the Aerospike DB
On error we expect to see:
Aerospike failed to connect[300]: failed to initialize cluster