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

updateDir() public method

Update directory
public updateDir ( string $key, integer $ttl ) : array
$key string
$ttl integer
return array $body
    public function updateDir($key, $ttl)
    {
        if (!$ttl) {
            throw new EtcdException('TTL is required', 204);
        }
        $condition = array('dir' => 'true', 'prevExist' => 'true');
        $request = $this->guzzleclient->put($this->buildKeyUri($key), null, array('ttl' => (int) $ttl), array('query' => $condition));
        $response = $request->send();
        $body = $response->json();
        if (isset($body['errorCode'])) {
            throw new EtcdException($body['message'], $body['errorCode']);
        }
        return $body;
    }

Usage Example

Example #1
0
 /**
  * @covers LinkORB\Component\Etcd\Client::updatedir
  */
 public function testUpdatedir()
 {
     $dirname = '/test_updatedir';
     $this->client->mkdir($dirname);
     $this->client->updateDir($dirname, 10);
     $dir = $this->client->listDir($dirname);
     $this->assertLessThanOrEqual(10, $dir['node']['ttl']);
 }
All Usage Examples Of LinkORB\Component\Etcd\Client::updateDir