• zk set 方法


    [root@wx03 zook]# cat a4.pl 
    use ZooKeeper;
    use AnyEvent;
    use AE;
    use Data::Dumper;
       my $zk = ZooKeeper->new(hosts => '127.0.0.1:2181');
       my $stat = $zk->exists('/zk01');
       if ($stat){
                  $zk->delete('/zk01');
        }
       my $created_path = $zk->create('/zk01', 'scan1000',
                                       ephemeral => 1, 
                                       sequential => 1,
                                       'acl' => ZOO_OPEN_ACL_UNSAFE);    
        ###获取数据
        print Dumper($zk->get("/zk01"));
    
       ###修改数据
        $zk->set('/zk01' =>'scan9912472388');
        print Dumper($zk->get("/zk01")); 
         my $cv = AE::cv;
        ###获取数据
        my @children = $zk->get('/zk01', watcher => sub { 
            ###事件状态
            my $event = shift;
            print "触发了事件.";
            print $event->{'type'}."
    ";
            print "事件状态.";
            print $event->{'state'}."
    ";
            $cv->send($event) });

  • 相关阅读:
    C# using
    Spring框架
    is
    pycharm破解197
    python安装197
    python3.7.0安装197
    centos7 minimal 安装mysql197
    centos7 minimal 安装 &网络配置197
    ruby安装卸载197
    redis安装 卸载 启动 关闭197
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199557.html
Copyright © 2020-2023  润新知