Skip to content

Latest commit

 

History

History
53 lines (36 loc) · 1.06 KB

aerospike_reconnect.md

File metadata and controls

53 lines (36 loc) · 1.06 KB

Aerospike::reconnect

Aerospike::reconnect - Reconnect to the Aerospike DB

Description

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.

Parameters

This method has no parameters.

See Also

Examples

<?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