update() public method

Update an existing key with a given value.
public update ( strint $key, string $value, integer $ttl, array $condition = [] ) : array
$key strint
$value string
$ttl integer
$condition array The extra condition for updating
return array $body
Exemplo n.º 1
0
 /**
  * @covers LinkORB\Component\Etcd\Client::update
  * @expectedException \LinkORB\Component\Etcd\Exception\KeyNotFoundException
  */
 public function testUpdate()
 {
     $key = '/testupdate_key';
     $value1 = 'value1';
     $value2 = 'value2';
     $this->client->update($key, $value1);
     $this->client->set($key, $value2);
     $value = $this->client->get($key);
     $this->assertEquals('value2', $value);
 }
Exemplo n.º 2
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $server = $input->getArgument('server');
     $key = $input->getArgument('key');
     $value = $input->getArgument('value');
     $ttl = $input->getOption('ttl');
     $output->writeln("<info>Update `{$value}` of `{$key}`</info>");
     $client = new EtcdClient($server);
     $data = $client->update($key, $value, $ttl);
     $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
     echo $json;
 }