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

Example #1
0
 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