Reputation: 6003
I am using aerospike on ubuntu.
I am able to set and get records on/from aerospike on the command line.
In PHP, I am able to instantiate the AeroSpike class, but when i try to add some data to it, it says "AEROSPIKE_ERR_NAMESPACE_NOT_FOUND".
Surprisingly, the error code is 20, where as it should be 501 as per the docs. There is no such error code 20 defined in the api.
https://github.com/aerospike/aerospike-client-nodejs/blob/master/docs/status.md
Code, that I tried.
<?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();
?>
Any help is welcome.
Thanks,
Upvotes: 3
Views: 836
Reputation: 3055
Is the namespace "infosphere" defined in your Aerospike server config?
https://www.aerospike.com/docs/operations/configure/namespace/
Default namespace present are only test and bar. Any other additional namespaces have to be defined and Aerospike server restarted to get the new namespace working.
I will check into the error codes.
Upvotes: 4