<?php
/* Connect to a database on default port */
$tt = new TokyoTyrant("localhost");
/* Create a new key */
$tt->put("key", "value");
try {
$tt->putKeep("key", "new value");
} catch (TokyoTyrantException $e) {
if ($e->getCode() === TokyoTyrant::TTE_KEEP) {
echo "Existing record! Not modified\n";
} else {
echo "Error: " , $e->getMessage() , "\n";
}
}
echo $tt->get("key");
?>
Результат выполнения данного примера:
Existing record! Not modified
value