Zookeeper::create
(PECL zookeeper >= 0.1.0)
Zookeeper::create — Create a node synchronously
说明
This method will create a node in ZooKeeper. A node can only be created if it does not already exists. The Create Flags affect the creation of nodes. If ZOO_EPHEMERAL flag is set, the node will automatically get removed if the client session goes away. If the ZOO_SEQUENCE flag is set, a unique monotonically increasing sequence number is appended to the path name.
参数
path- 
     
The name of the node. Expressed as a file name with slashes separating ancestors of the node.
 value- 
     
The data to be stored in the node.
 acls- 
     
The initial ACL of the node. The ACL must not be null or empty.
 flags- 
     
this parameter can be set to 0 for normal create or an OR of the Create Flags
 
返回值
Returns the path of the new node (this might be different than the supplied path because of the ZOO_SEQUENCE flag) on success, and false on failure.
错误/异常
This method emits PHP error/warning when parameters count or types are wrong or fail to create node.
Since version 0.3.0, this method emits ZookeeperException and it's derivatives.
示例
示例 #1 Zookeeper::create() example
Create a new node.
<?php
$zookeeper = new Zookeeper('locahost:2181');
$aclArray = array(
  array(
'perms'  => Zookeeper::PERM_ALL,
'scheme' => 'world',
'id'     => 'anyone',
  )
);
$path = '/path/to/newnode';
$realPath = $zookeeper->create($path, null, $aclArray);
if ($realPath)
  echo $realPath;
else
  echo 'ERR';
?>以上示例会输出:
/path/to/newnode
参见
- Zookeeper::delete() - Delete a node in zookeeper synchronously
 - Zookeeper::getChildren() - Lists the children of a node synchronously
 - ZooKeeper Permissions
 - ZookeeperException