python
正确配置 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; // 两分钟 } } }
- python 2018-10-15 已签到连续签到3天,获得了15个金钱
- python 2018-10-14 已签到连续签到2天,获得了10个金钱
- python 2018-10-13 已签到连续签到1天,获得了5个金钱
- python 2018-10-11 已签到连续签到5天,获得了20个金钱
- python 2018-10-10 已签到连续签到4天,获得了20个金钱
- python 2018-10-09 已签到连续签到3天,获得了15个金钱
- python 发表了说说哈士奇哪里去了?文章也不审。
- python 2018-10-08 已签到连续签到2天,获得了10个金钱