Example #1
0
    if ($db->isConnected()) {
        for ($i = 0; $i < 100; $i++) {
            $key = $db->initKey("test", "demo", "key" . $i);
            $status = $db->remove($key);
            if ($status != Aerospike::OK) {
                echo "Remove failed at " . $i . "th record";
                break;
            }
        }
        $db->close();
    } else {
        echo "Aerospike DB connection is not established";
    }
});
$app->put('/closeconnection', function () use($db) {
    $status = $db->close();
    if ($status != Aerospike::OK) {
        echo "Connection is already closed";
        exit(1);
    }
    echo "Connection to the Aerospike database closed";
});
$app->get('/reconnect', function () use($db) {
    $status = $db->reconnect();
    if ($status != Aerospike::OK) {
        echo "Already connected to the Aerospike DB";
        exit(1);
    }
    echo "Connection re-established to the Aerospike database";
});
$app->run();