3

ubuntuでエアロスパイクを使用しています。

コマンド ラインで aerospike のレコードを設定および取得できます。

PHP では、AeroSpike クラスをインスタンス化できますが、それにデータを追加しようとすると、「AEROSPIKE_ERR_NAMESPACE_NOT_FOUND」と表示されます。

驚くべきことに、エラー コードは 20 ですが、ドキュメントでは 501 である必要があります。APIで定義されたそのようなエラーコード20はありません。

https://github.com/aerospike/aerospike-client-nodejs/blob/master/docs/status.md

私が試したコード。

<?php
ini_set( 'display_errors', 1 );
ini_set( 'error_reporting', E_ALL );

// set the records to never expire unless specified otherwise
define( 'RECORD_TIME_TO_LIVE', 0 );

$config = array(
    "hosts" => array(
        array( "addr" => "127.0.0.1", "port" => 3000 )
    )
);

$db = new Aerospike( $config );

// failure check
if ( !$db->isConnected() ) {
    echo "Failed to connect to the Aerospike server [{$db->errorno()}]: {$db->error()}\n";
    exit( 1 );
}

$key = $db->initKey("infosphere", "characters", 1);

$put_vals = array("name" => "Scruffy", "Occupation" => "The Janitor");

$status = $db->put($key, $put_vals, RECORD_TIME_TO_LIVE);

if($status == Aerospike::OK) {
    echo "Record written.\n";
} elseif ($status == Aerospike::ERR_RECORD_EXISTS) {
    echo "The Aerospike server already has a record with the given key.\n";
} else {
    echo "[{$db->errorno()}] :".$db->error();
}

$db->close();
?>

どんな助けでも大歓迎です。

ありがとう、

4

1 に答える 1

4

名前空間「infosphere」は Aerospike サーバー構成で定義されていますか?

https://www.aerospike.com/docs/operations/configure/namespace/

存在するデフォルトの名前空間は、test と bar のみです。新しい名前空間を機能させるには、その他の追加の名前空間を定義し、Aerospike サーバーを再起動する必要があります。

エラーコードを調べてみます。

于 2015-02-16T14:53:50.113 に答える