PHP Class LinkORB\Component\Etcd\Client

Show file Open project: linkorb/etcd-php Class Usage Examples

Public Methods

Method Description
__construct ( $server = '', $version = 'v2' )
doRequest ( string $uri ) : mixed Do a server request
get ( string $key, array $flags = null ) : string Retrieve the value of a key
getKeysValue ( $root = '/', boolean $recursive = true, string $key = null ) : array Get all key-value pair that the key is not directory.
getNode ( string $key, array $flags = null ) : array Retrieve the value of a key
listDir ( string $key = '/', boolean $recursive = false ) : mixed Retrieve a directory
ls ( string $key = '/', boolean $recursive = false ) : array Retrieve a directories key
mk ( string $key, string $value, integer $ttl ) : array make a new key with a given value
mkdir ( string $key, integer $ttl ) : array make a new directory
mkdirWithInOrderKey ( string $dir, integer $ttl ) : array create a new directory with auto generated id
rm ( string $key ) : array | stdClas\stdClass remove a key
rmdir ( string $key, boolean $recursive = false ) : mixed Removes the key if it is directory
set ( string $key, string $value, integer $ttl = null, array $condition = [] ) : stdClass Set the value of a key
setRoot ( string $root ) : Client Set the default root directory. the default is / If the root is others e.g. /linkorb when you set new key, or set dir, all of the key is under the root e.g.
setWithInOrderKey ( string $dir, string $value, integer $ttl, array $condition = [] ) : array create a new key in a directory with auto generated id
update ( strint $key, string $value, integer $ttl, array $condition = [] ) : array Update an existing key with a given value.
updateDir ( string $key, integer $ttl ) : array Update directory

Private Methods

Method Description
buildKeyUri ( string $key ) : string Build key space operations
traversalDir ( RecursiveArrayIterator $iterator ) : array Traversal the directory to get the keys.

Method Details

__construct() public method

public __construct ( $server = '', $version = 'v2' )

doRequest() public method

Do a server request
public doRequest ( string $uri ) : mixed
$uri string
return mixed

get() public method

Retrieve the value of a key
public get ( string $key, array $flags = null ) : string
$key string
$flags array the extra query params
return string the value of the key.

getKeysValue() public method

Get all key-value pair that the key is not directory.
public getKeysValue ( $root = '/', boolean $recursive = true, string $key = null ) : array
$recursive boolean
$key string
return array

getNode() public method

Retrieve the value of a key
public getNode ( string $key, array $flags = null ) : array
$key string
$flags array the extra query params
return array

listDir() public method

Retrieve a directory
public listDir ( string $key = '/', boolean $recursive = false ) : mixed
$key string
$recursive boolean
return mixed

ls() public method

Retrieve a directories key
public ls ( string $key = '/', boolean $recursive = false ) : array
$key string
$recursive boolean
return array

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

mkdir() public method

make a new directory
public mkdir ( string $key, integer $ttl ) : array
$key string
$ttl integer
return array $body

mkdirWithInOrderKey() public method

create a new directory with auto generated id
public mkdirWithInOrderKey ( string $dir, integer $ttl ) : array
$dir string
$ttl integer
return array $body

rm() public method

remove a key
public rm ( string $key ) : array | stdClas\stdClass
$key string
return array | stdClas\stdClass

rmdir() public method

Removes the key if it is directory
public rmdir ( string $key, boolean $recursive = false ) : mixed
$key string
$recursive boolean
return mixed

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

setRoot() public method

$client->setRoot('/linkorb'); $client->set('key1, 'value1'); the new key is /linkorb/key1
public setRoot ( string $root ) : Client
$root string
return Client

setWithInOrderKey() public method

create a new key in a directory with auto generated id
public setWithInOrderKey ( string $dir, string $value, integer $ttl, array $condition = [] ) : array
$dir string
$value string
$ttl integer
$condition array
return array $body

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

updateDir() public method

Update directory
public updateDir ( string $key, integer $ttl ) : array
$key string
$ttl integer
return array $body