国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

使用 GatewayWorker + redis 使用出現(xiàn)問題

duoduo

使用 GatewayWorker + redis 使用出現(xiàn)問題,

我在 Events.php 中做如下處理

public static function onWorkerStart($businessWorker) 中初始化redis 

      $redis = new redis();
          $redis -> connect('127.0.0.1',6379);
          echo "啟動(dòng)redis\n";

public static function onMessage($client_id, $message) 中存儲(chǔ)數(shù)據(jù)

         $redis->zAdd($key, $i, $redis_str);

但是啟動(dòng)后,顯示如下錯(cuò)誤:

PHP Notice:  Undefined variable: redis in /GatewayWorker/Applications/YourApp/Events.php on line 149

Notice: Undefined variable: redis in /GatewayWorker/Applications/YourApp/Events.php on line 149
PHP Fatal error:  Call to a member function zAdd() on a non-object in /GatewayWorker/Applications/YourApp/Events.php on line 149

Fatal error: Call to a member function zAdd() on a non-object in /GatewayWorker/Applications/YourApp/Events.php on line 149
WORKER EXIT UNEXPECTED E_ERROR Call to a member function zAdd() on a non-object in /GatewayWorker/Applications/YourApp/Events.php on line 149
worker exit with status 65280
啟動(dòng)redis

不曉得是何原因哦,偶是新手,請(qǐng)各位大哥多多指點(diǎn),感激不盡。

8811 1 0
1個(gè)回答

damao

哈哈,php基礎(chǔ)不過關(guān)。
給你個(gè)手冊(cè)學(xué)習(xí)下
http://php.net/manual/zh/language.variables.scope.php

  • duoduo 2016-11-25

    大哥您好,實(shí)在是初學(xué)哦,我是看這里介紹的http://www.wtbis.cn/gatewaydoc/gateway-worker-development/onworkerstart.html
    正確的寫法如何能否指點(diǎn)下,謝謝您。

  • fff 2016-11-25

    private $_redis;
    public static function onWorkerStart($businessWorker) {
    $redis = new redis();
    $redis -> connect('127.0.0.1',6379);
    $this->_redis=$redis;
    echo "啟動(dòng)redis\n";
    }

    public static function onMessage($client_id, $message) {
    $this->_redis->zAdd($key, $i, $redis_str);
    }

  • duoduo 2016-11-30

    @1424:您好,您這個(gè)也是有報(bào)錯(cuò)的。 靜態(tài)方法中要用 self:: ,但是修改后也是有報(bào)錯(cuò)。郁悶了

  • damao 2016-12-03

    其實(shí)把上面手冊(cè)那里基礎(chǔ)看懂就會(huì)了

年代過于久遠(yuǎn),無法發(fā)表回答
??