PHP Class LinkORB\Component\Etcd\Client

Afficher le fichier Open project: linkorb/etcd-php Class Usage Examples

Méthodes publiques

Méthode 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

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

Method Details

__construct() public méthode

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

doRequest() public méthode

Do a server request
public doRequest ( string $uri ) : mixed
$uri string
Résultat mixed

get() public méthode

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

getKeysValue() public méthode

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
Résultat array

getNode() public méthode

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

listDir() public méthode

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

ls() public méthode

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

mk() public méthode

make a new key with a given value
public mk ( string $key, string $value, integer $ttl ) : array
$key string
$value string
$ttl integer
Résultat array $body

mkdir() public méthode

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

mkdirWithInOrderKey() public méthode

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

rm() public méthode

remove a key
public rm ( string $key ) : array | stdClas\stdClass
$key string
Résultat array | stdClas\stdClass

rmdir() public méthode

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

set() public méthode

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
Résultat stdClass

setRoot() public méthode

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

setWithInOrderKey() public méthode

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
Résultat array $body

update() public méthode

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
Résultat array $body

updateDir() public méthode

Update directory
public updateDir ( string $key, integer $ttl ) : array
$key string
$ttl integer
Résultat array $body