php-zookeeper icon indicating copy to clipboard operation
php-zookeeper copied to clipboard

watcher not work

Open krowkrow opened this issue 7 years ago • 1 comments

`$zk->get('/test', 'mywatch');

function mywatch($eventType, $eventState, $eventKey) { echo 'listen node'; print_r(func_get_args()); } `

i add node /test/a, or remove it, mywatch function not work,

PHP7.0.24 NTS

krowkrow avatar Jan 18 '18 03:01 krowkrow

According to ZooKeeper Programmer's Guide[1],

getData() and exists() set data watches. getChildren() sets child watches

So,

A successful create() will trigger a data watch for the znode being created and a child watch for the parent znode. A successful delete() will trigger both a data watch and a child watch (since there can be no more children) for a znode being deleted as well as a child watch for the parent znode.

[1] http://zookeeper.apache.org/doc/r3.5.3-beta/zookeeperProgrammers.html#ch_zkWatches

Timandes avatar Jan 20 '18 14:01 Timandes