コード例 #1
0
 public static function sendMessage($body)
 {
     if (Yii::app()->params['USE_BEANSTALK'] === '0') {
         return false;
     }
     //Connect to the queue
     $queue = new Phalcon\Queue\Beanstalk(array('host' => Yii::app()->params['BEANSTALK_SERVER'], 'port' => Yii::app()->params['BEANSTALK_PORT']));
     $queue->choose(Yii::app()->params['TUBE_PLAY_HISTORY']);
     //Insert the job in the queue
     $queue->put($body);
 }
コード例 #2
0
ファイル: BeanstalkTest.php プロジェクト: UqiOnline/cphalcon7
 public function testReleaseKickBury()
 {
     $queue = new Phalcon\Queue\Beanstalk();
     try {
         @$queue->connect();
     } catch (Exception $e) {
         $this->markTestSkipped($e->getMessage());
         return;
     }
     $this->assertTrue($queue->choose('beanstalk-test') !== false);
     $task = 'doSomething';
     $this->assertTrue($queue->put($task) !== false);
     $this->assertTrue($queue->watch('beanstalk-test') !== false);
     $job = $queue->reserve(0);
     $this->assertTrue($job !== false);
     $this->assertEquals($task, $job->getBody());
     $this->assertTrue($job->touch());
     // Release the job; it moves to the ready queue
     $this->assertTrue($job->release());
     $job = $queue->reserve(0);
     $this->assertTrue($job !== false);
     $this->assertEquals($task, $job->getBody());
     // Bury the job
     $this->assertTrue($job->bury());
     $job = $queue->peekBuried();
     $this->assertTrue($job !== false);
     $this->assertEquals($task, $job->getBody());
     // Kick the job, it should move to the ready queue again
     // kick-job is supported since 1.8
     if (false !== $job->kick()) {
         $job = $queue->peekReady();
         $this->assertTrue($job !== false);
         $this->assertEquals($task, $job->getBody());
     }
     $this->assertTrue($job->delete());
 }
コード例 #3
0
ファイル: BeanstalkTest.php プロジェクト: acwtools/cphalcon
 public function testStats()
 {
     $queue = new Phalcon\Queue\Beanstalk();
     try {
         @$queue->connect();
     } catch (Exception $e) {
         $this->markTestSkipped($e->getMessage());
         return;
     }
     $this->assertTrue($queue->choose('beanstalk-test') !== false);
     $queueStats = $queue->stats();
     $this->assertTrue(is_array($queueStats));
     $tubeStats = $queue->statsTube('beanstalk-test');
     $this->assertTrue(is_array($tubeStats));
     $this->assertTrue($tubeStats['name'] === 'beanstalk-test');
     $this->assertTrue($queue->statsTube('beanstalk-test-does-not-exist') === false);
     $this->assertTrue($queue->choose('beanstalk-test') !== false);
     $queue->put('doSomething');
     $queue->watch('beanstalk-test');
     $job = $queue->peekReady();
     $jobStats = $job->stats();
     $this->assertTrue(is_array($jobStats));
     $this->assertTrue($jobStats['tube'] === 'beanstalk-test');
 }
コード例 #4
0
ファイル: redword.php プロジェクト: tianyunchong/php
    }
    foreach ($mysqlRs as $value) {
        $id = $value["id"];
        if (!strstr($value["redword"], "+")) {
            continue;
        }
        echo $value["keyword"] . "\n";
        echo $value["redword"];
        echo "\n";
        $redword = str_replace("+", "", $value["redword"]);
        $redword = preg_replace("/[\\s]+/is", " ", $redword);
        echo $redword;
        echo "\n";
        $conn->update("update gckeyword.key_proword set redword = '" . $redword . "' where id = '" . $value["id"] . "'");
        try {
            $beanstalk->choose('v3www_prokeyword_cachewrite');
            echo $beanstalk->put($value["keyword"], array('priority' => 1024, 'delay' => 0, 'ttr' => 86400)), "\n";
        } catch (\Exception $e) {
        }
        exit;
    }
}
class Config
{
    public static $dbArr = array('localhost' => array('192.168.12.70', "root", "123456", "test"), 'online' => array('192.168.2.163', "gongchangdb", "gongchangdb7232275", "caijiproductinfo"), 'info' => array('192.168.2.101', 'hangye', 'hangye7232275', 'hangye'), 'local' => array('192.168.8.18', 'root', 'gc7232275', 'gcoperate'), "local170" => array('192.168.8.170', "root", "gc7232275", "test"), 'local189' => array('192.168.8.189', 'gongchang', 'gongchang123', 'gckeyword'), 'main' => array('read.mysql.ch.gongchang.com', 'gcwork', 'gcwork7232275', 'catesearch'), 'maind' => array('write.mysql.ch.gongchang.com', 'gcwork', 'gcwork7232275', 'catesearch'), "product" => array("pdinfo.read.mysql.ch.gongchang.com", "gccontent", "gccontent7232275", "caijiproductinfo"), 'club' => array('55651c3e54ae6.sh.cdb.myqcloud.com', 'cdb_outerroot', 'ScIwH*3fEB(', 'cn_clubnew', 8287), 'txonline' => array('172.17.18.4', 'gckeyword', 'WVwVaxADjX9z3PHd', 'gckeyword'));
    public static $cateApiUrl = 'http://cate.ch.gongchang.com/cate_json/';
}
class Table
{
    public $conn = '';
    public $config;
コード例 #5
0
ファイル: comkeyword.php プロジェクト: tianyunchong/php
<?php

/**
 * 初始化一条企业关键词的beanstalk数据
 */
define("App", "product");
if (App == "dev") {
    $config = array('192.168.8.189', 11300);
} elseif (App == "product") {
    $config = array('172.17.16.101', 11300);
} elseif (App == "test") {
} else {
    exit("未知的环境!");
}
$queue = new \Phalcon\Queue\Beanstalk(array("host" => $config[0], "port" => $config[1]));
try {
    $queue->choose('v3www_comkeyword_init');
    echo $queue->put("机械机床护罩", array('priority' => 1024, 'delay' => 0, 'ttr' => 86400)), "\n";
} catch (\Exception $e) {
}
コード例 #6
0
ファイル: prokeyword.php プロジェクト: tianyunchong/php
<?php

/**
 * 初始化一条产品关键词的beanstalk数据
 */
define("App", "product");
if (App == "dev") {
    $config = array('192.168.8.189', 11300);
} elseif (App == "product") {
    $config = array('172.17.16.101', 11300);
} elseif (App == "test") {
} else {
    exit("未知的环境!");
}
$queue = new \Phalcon\Queue\Beanstalk(array("host" => $config[0], "port" => $config[1]));
try {
    $queue->choose('v3www_prokeyword_rela');
    echo $queue->put(9942738, array('priority' => 1024, 'delay' => 0, 'ttr' => 86400)), "\n";
} catch (\Exception $e) {
}
コード例 #7
0
ファイル: keywordquanmao.php プロジェクト: tianyunchong/php
$id = 0;
$conn = new Table("txonline");
$beanstalk = new \Phalcon\Queue\Beanstalk(array("host" => "172.17.16.101", "port" => 11300));
while (1) {
    $keywordMysql = $conn->findAll("select id, keyword, relacateid from gckeyword.key_proword where id > '{$id}' order by id asc limit 100");
    if (empty($keywordMysql)) {
        exit("所有数据处理完毕");
    }
    foreach ($keywordMysql as $value) {
        $id = $value["id"];
        if (!strstr($value["relacateid"], "1270")) {
            continue;
        }
        $conn->update("update gckeyword.key_proword set relacateid = '' where id = '" . $value["id"] . "'");
        try {
            $beanstalk->choose('v3www_prokeyword_rela');
            echo $beanstalk->put($value["id"], array('priority' => 1024, 'delay' => 0, 'ttr' => 86400)), "\n";
        } catch (\Exception $e) {
        }
        exit;
    }
}
class Config
{
    public static $dbArr = array('localhost' => array('192.168.12.70', "root", "123456", "test"), 'online' => array('192.168.2.163', "gongchangdb", "gongchangdb7232275", "caijiproductinfo"), 'info' => array('192.168.2.101', 'hangye', 'hangye7232275', 'hangye'), 'local' => array('192.168.8.18', 'root', 'gc7232275', 'gcoperate'), "local170" => array('192.168.8.170', "root", "gc7232275", "test"), 'local189' => array('192.168.8.189', 'gongchang', 'gongchang123', 'gckeyword'), 'main' => array('read.mysql.ch.gongchang.com', 'gcwork', 'gcwork7232275', 'catesearch'), 'maind' => array('write.mysql.ch.gongchang.com', 'gcwork', 'gcwork7232275', 'catesearch'), "product" => array("pdinfo.read.mysql.ch.gongchang.com", "gccontent", "gccontent7232275", "caijiproductinfo"), 'club' => array('55651c3e54ae6.sh.cdb.myqcloud.com', 'cdb_outerroot', 'ScIwH*3fEB(', 'cn_clubnew', 8287), 'txonline' => array('172.17.18.4', 'gckeyword', 'WVwVaxADjX9z3PHd', 'gckeyword'));
    public static $cateApiUrl = 'http://cate.ch.gongchang.com/cate_json/';
}
class Table
{
    public $conn = '';
    public $config;