Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 1.9 KB

aerospike_remove.md

File metadata and controls

61 lines (43 loc) · 1.9 KB

Aerospike::remove

Aerospike::remove - removes a record from the Aerospike database

Description

public int Aerospike::remove ( array $key [, array $options ] )

Aerospike::remove() will remove a record with a given key from the database.

Parameters

key the key for the record. An array with keys ['ns','set','key'] or ['ns','set','digest'].

options including

Return Values

Returns an integer status code. Compare to the Aerospike class status constants. When non-zero the Aerospike::error() and Aerospike::errorno() methods can be used.

Examples

<?php

$config = ["hosts" => [["addr"=>"localhost", "port"=>3000]], "shm"=>[]];
$client = new Aerospike($config, true);
if (!$client->isConnected()) {
   echo "Aerospike failed to connect[{$client->errorno()}]: {$client->error()}\n";
   exit(1);
}

$key = $client->initKey("test", "users", 1234);
$status = $client->remove($key, array(Aerospike::OPT_POLICY_RETRY => Aerospike::POLICY_RETRY_NONE));
if ($status == Aerospike::OK) {
    echo "Record removed.\n";
} elseif ($status == Aerospike::ERR_RECORD_NOT_FOUND) {
    echo "A user with key ". $key['key']. " does not exist in the database\n";
} else {
    echo "[{$client->errorno()}] ".$client->error();
}

?>

We expect to see:

Record removed.