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

set() public method

Set the value of a key
public set ( string $key, string $value, integer $ttl = null, array $condition = [] ) : stdClass
$key string
$value string
$ttl integer
$condition array
return stdClass
    public function set($key, $value, $ttl = null, $condition = array())
    {
        $data = array('value' => $value);
        if ($ttl) {
            $data['ttl'] = $ttl;
        }
        $request = $this->guzzleclient->put($this->buildKeyUri($key), null, $data, array('query' => $condition));
        $response = $request->send();
        $body = $response->json();
        return $body;
    }

Usage Example

コード例 #1
0
ファイル: ClientTest.php プロジェクト: LeeSaferite/etcd-php
 public function testGetNode()
 {
     $key = 'node_key';
     $setdata = $this->client->set($key, 'node_value');
     $node = $this->client->getNode($key);
     $this->assertJsonStringEqualsJsonString(json_encode($node), json_encode($setdata['node']));
 }
All Usage Examples Of LinkORB\Component\Etcd\Client::set