LinkORB\Component\Etcd\Client::mk PHP Method

mk() public method

make a new key with a given value
public mk ( string $key, string $value, integer $ttl ) : array
$key string
$value string
$ttl integer
return array $body
    public function mk($key, $value, $ttl = 0)
    {
        $body = $request = $this->set($key, $value, $ttl, array('prevExist' => 'false'));
        if (isset($body['errorCode'])) {
            throw new KeyExistsException($body['message'], $body['errorCode']);
        }
        return $body;
    }

Usage Example

コード例 #1
0
ファイル: EtcdMkCommand.php プロジェクト: gfyrag/etcd-php
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $server = $input->getArgument('server');
     $key = $input->getArgument('key');
     $value = $input->getArgument('value');
     $output->writeln("<info>Create `{$key}` with `{$value}`</info>");
     $client = new EtcdClient($server);
     $data = $client->mk($key, $value);
     $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
     echo $json;
 }
All Usage Examples Of LinkORB\Component\Etcd\Client::mk