python

python

这家伙有点懒,还没写个性签名!

  • 财富值3555
  • 威望值30
  • 总积分4035

个人信息

  • 正确配置 queue,使其记录日志。

    'queue' => [
        'class'     => 'yii\queue\db\Queue',
        'db'        => 'db',                     // DB connection component or its config 
        'tableName' => '{{%queue}}',             // Table name
        'channel'   => 'default',                // Queue channel key
        'mutex'     => 'yii\mutex\MysqlMutex',   // Mutex used to sync queries
        'as log'    => \yii\queue\LogBehavior::class,
    ],
    
  • 回答了问题 队列消息
    <?php
    
    
    function main() {
        Yii::$app->queue->push(new SendLinkJob([
            'link' => 'https://baidu.com',
            'startAt' => time(),
            'times' => 1,
        ]));
    }
    
    
    class SendLinkJob extends BaseObject implements \yii\queue\JobInterface {
    
        public $link;
        public $startAt;
        public $times;
    
        public function execute($queue)
        {
            if (! $this->isLinkValid()) {
                return false;
            }
            if (4 == $this->times) {
                return $this->sendToService();
            }
            
            $this->sendLink();
            Yii::$app->queue->delay($this->getDelay())->push(new SendLinkJob([
                'link'    => $this->link,
                'startAt' => $this->startAt,
                'times'   => ++$this->times,
            ]));
        }
    
        public function isLinkValid()
        {
            // ...
            return true;
        }
    
        public function sendLink()
        {
            // 发链接到客服端
        }
    
        public function sendToService()
        {
            // 发到客服
        }
    
        protected function getDelay()
        {
            switch ($this->times) {
                case 1 :
                return 180; /* 三分钟 */
                case 2 :
                return 120; /* 两分钟 */
                case 3 :
                return 120; // 两分钟
            }
        }
    }
    
  • 2018-10-15 已签到
    连续签到3天,获得了15个金钱
  • 2018-10-14 已签到
    连续签到2天,获得了10个金钱
  • 2018-10-13 已签到
    连续签到1天,获得了5个金钱
  • 2018-10-11 已签到
    连续签到5天,获得了20个金钱
  • 2018-10-10 已签到
    连续签到4天,获得了20个金钱
  • 2018-10-09 已签到
    连续签到3天,获得了15个金钱
  • 发表了说说
    哈士奇哪里去了?文章也不审。
  • 2018-10-08 已签到
    连续签到2天,获得了10个金钱
总监 等级规则
4035/5000
资料完整度
10/100
用户活跃度
0/100

Ta的关注

0

Ta的粉丝

3

Ta的访客

19