rm() public method

remove a key
public rm ( string $key ) : array | stdClas\stdClass
$key string
return array | stdClas\stdClass
Exemplo n.º 1
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $server = $input->getArgument('server');
     $key = $input->getArgument('key');
     $output->writeln("<info>Removing key `{$key}`</info>");
     $client = new EtcdClient($server);
     $data = $client->rm($key);
     $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
     echo $json;
 }
Exemplo n.º 2
0
 /**
  * @covers LinkORB\Component\Etcd\Client::rm
  * @expectedException \LinkORB\Component\Etcd\Exception\EtcdException
  */
 public function testRm()
 {
     $this->client->rm('/rmkey');
 }
Exemplo n.º 3
0
echo "Refreshing lock, timeout of 3 seconds\n";
$result1 = $client->set("/{$connector_id}", $jobPid, 3, ['prevValue' => $jobPid]);
print_r($result1);
echo "\n";
// get key value
echo "Checking if key has expired\n";
try {
    echo "Key Value: " . $client->get("/{$connector_id}") . "\n\n";
} catch (Exception $e) {
    echo "Key Not Found: {$connector_id}\n\n";
}
echo "Attemping to set value\n";
$result2 = $client->set("/{$connector_id}", $jobPid . "-next2", 3, ['prevExist' => 'false']);
print_r($result2);
echo "\n";
// get key value
try {
    echo "Key Value: " . $client->get("/{$connector_id}") . "\n\n";
} catch (Exception $e) {
    echo "Key Not Found: {$connector_id}\n\n";
}
// Delete key
try {
    echo "Deleting Key\n";
    print_r($client->rm("/{$connector_id}"));
} catch (Exception $e) {
    echo "Key Not Found: {$connector_id}\n";
}
echo "\n";
echo "Printing directory tree\n";
print_r($client->listDir('/', true));