Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 2.37 KB

aerospike_prepend.md

File metadata and controls

69 lines (49 loc) · 2.37 KB

Aerospike::prepend

Aerospike::prepend - prepends a string to the string value in a bin

Description

public int Aerospike::prepend ( array $key, string $bin, string $value [, array $options ] )

Aerospike::prepend() will prepend a string to the string value in bin. Like other bin operations, prepend() only works on existing records (i.e. ones that were previously created with a put()).

Parameters

key the key under which the bin can be found. An array with keys ['ns','set','key'] or ['ns','set','digest'].

bin the name of the bin in which we have a numeric value.

value the string to prepend to the string value in the bin.

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);
$options = [Aerospike::OPT_TTL => 3600];
$status = $client->prepend($key, 'name', '*', $options);
if ($status == Aerospike::OK) {
    echo "Starred the user.\n";
} else {
    echo "[{$client->errorno()}] ".$client->error();
}

?>

We expect to see:

Starred the user.