$HOST_ADDR = isset($args["h"]) ? (string) $args["h"] : (isset($args["host"]) ? (string) $args["host"] : "127.0.0.1");
$HOST_PORT = isset($args["p"]) ? (int) $args["p"] : (isset($args["port"]) ? (string) $args["port"] : 3000);
if (isset($args['a']) || isset($args['annotate'])) {
    $annotate = true;
} else {
    $annotate = false;
}
echo colorize("***** Welcome to Aerospike Developer Training *****\n", 'blue', true);
echo colorize("Connecting to Aerospike cluster ≻", 'black', true);
if ($annotate) {
    display_code(__FILE__, __LINE__, 7);
}
$config = array("hosts" => array(array("addr" => $HOST_ADDR, "port" => $HOST_PORT)));
$client = new Aerospike($config, false);
if (!$client->isConnected()) {
    echo standard_fail($client);
    echo colorize("Connection to Aerospike cluster failed! Please check the server settings and try again!\n", 'red', true);
    exit(2);
}
echo success();
$selection = show_menu();
if ($selection === 0) {
    $client->close();
    exit(0);
}
$user_service = new \Aerospike\Training\UserService($client, $config, $annotate);
$tweet_service = new \Aerospike\Training\TweetService($client, $config, $annotate);
try {
    switch ($selection) {
        case 1:
            $username = $user_service->createUser();
示例#2
0
$start = __LINE__;
$status = $db->scan("test", null, function ($record) {
    if (array_key_exists('email', $record['bins']) && !is_null($record['bins']['email']) && array_key_exists('name', $record['bins']) && !is_null($record['bins']['name'])) {
        echo "\n({$record['key']['ns']},{$record['key']['set']}," . base64_encode($record['key']['digest']) . ")";
    }
});
if ($status != AEROSPIKE::OK) {
    echo standard_fail($db);
} else {
    echo success();
}
if (isset($args['a']) || isset($args['annotate'])) {
    display_code(__FILE__, $start, __LINE__);
}
if (isset($args['a']) || isset($args['clean'])) {
    $start = __LINE__;
    echo colorize("Removing the record ≻", 'black', true);
    $key = $db->initKey("test", "users", 1234);
    $status = $db->remove($key);
    $key = $db->initKey("test", "users", 2345);
    $status = $db->remove($key);
    if ($status == Aerospike::OK) {
        echo success();
    } else {
        echo standard_fail($db);
    }
    if (isset($args['a']) || isset($args['annotate'])) {
        display_code(__FILE__, $start, __LINE__);
    }
}
$db->close();