我在ubuntu上使用Aeropike。
我能够在指挥线上的Aeropike上设置和获取记录。
在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();
?>
欢迎任何帮助。
谢谢,
Aerospike服务器配置中是否定义了命名空间"infosphere"?
https://www.aerospike.com/docs/operations/configure/namespace/
存在的默认命名空间仅为test和bar。必须定义任何其他额外的名称空间,并重新启动Aerospike服务器以使新名称空间正常工作。
我将检查错误代码。