<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ? 強烈推薦使用think-queue ,[傳送門?](https://blog.csdn.net/qq_34050360/article/details/116986237 "傳送門?")? 一、安裝Redis 二、修改Redis配置如下所示,并重啟: 這里需要配置 notify-keyspace-events 的參數為 “Ex”。x 代表了過期事件。notify-keyspace-events “Ex” 保存配置后,重啟Redis服務,使配置生效。 三、安裝php的Redis擴展 四、在? \\think\\cache\\driver\\Redis()? 添加幾個方法,或者重新定義一個Redis方法: ~~~php /*自定義Redis*/ public function setex($key, $time, $val) { return $this->handler->setex($key, $time, $val); } public function expire($key = null, $time = 0) { return $this->handler->expire($key, $time); } public function psubscribe($patterns = array(), $callback) { $this->handler->psubscribe($patterns, $callback); } public function setOption() { $this->handler->setOption(\Redis::OPT_READ_TIMEOUT, -1); } /*自定義Redis*/ ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") 五、application\\command.php? 新增一個?? ~~~php <?php return [ 'app\api\controller\Gopush', //腳本推送進程常駐 ]; ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") 六、新建控制器?app\\api\\controller\\Gopush ~~~php <?php namespace app\api\controller; use think\Controller; use think\Request; use think\console\Command; use think\console\Input; use think\console\Output; class Gopush extends Command { protected function configure() { $this->setName('gopush')->setDescription('Here is the gopush'); } protected function execute(Input $input, Output $output) { $redis = new \think\cache\driver\Redis(); $redis->setOption(); // $redis->psubscribe(array('__keyevent@0__:expired'), 'keyCallback'); $redis->psubscribe(array('__keyevent@0__:expired'), function ($redis, $pattern, $channel, $msg){ echo PHP_EOL; echo "Pattern: $pattern\n"; echo "Channel: $channel\n"; echo "Payload: $msg\n\n"; //................ /*TODO處理業務邏輯*/ }); $output->writeln("TestCommand:998998998"); } // public static function keyCallback($redis, $pattern, $chan, $msg) // { // echo "Pattern: $pattern\n"; // echo "Channel: $chan\n"; // echo "Payload: $msg\n\n"; // //keyCallback為訂閱事件后的回調函數,這里寫業務處理邏輯, // //比如前面提到的商品不支付自動撤單,這里就可以根據訂單id,來實現自動撤單 // } } ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") ### 七、執行命令? php think gopush 讓進程在終端運行(后面放到常駐進程里面去?supervisor),如下圖所示 (**重點:每次修改了東西,守護進程要進行重啟才有效**)(啟動如果一直失敗,就將啟動用戶改為root) ![](https://img-blog.csdnimg.cn/20201020162512685.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0MDUwMzYw,size_16,color_FFFFFF,t_70)![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動")?編輯 ![](https://img-blog.csdnimg.cn/2020102015380388.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0MDUwMzYw,size_16,color_FFFFFF,t_70)![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動")?編輯 八、觸發方法:$key 可以用來做需要的內容數據拼接,時間可以根據訂單倒計時算出來秒數,第三個參數只是備注 ~~~php /*這個格式去推送消息-用戶設置的時候處理*/ public function r3(){ $re=new Redis(); $key='推送別名-內容ID-用戶ID'; $re->setex($key,3,'redis延遲任務'); //3秒后回調 } ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") 九、thinkphp自定義命令?[自定義命令行 · ThinkPHP5.0完全開發手冊 · 看云](http://www.hmoore.net/manual/thinkphp5/235129 "自定義命令行 · ThinkPHP5.0完全開發手冊 · 看云")? 可以看著理解,很簡單的 十、參考博客,都是原生的,最后還得封裝,我都給你們封裝好了 [參考地址一](https://blog.csdn.net/weixin_30535043/article/details/99357330?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param "參考地址一") [參考地址二](https://www.cnblogs.com/idjl/p/9610538.html "參考地址二") [參考地址三](https://blog.csdn.net/jj546630576/article/details/80340573?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param "參考地址三") [參考地址四](https://blog.csdn.net/assasin0308/article/details/90261104?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param "參考地址四") [參考地址五](https://github.com/chenlinzhong/php-delayqueue "參考地址五") [參考地址六](https://blog.csdn.net/weixin_30856965/article/details/96166152?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param "參考地址六") [參考地址七](https://blog.csdn.net/ligupeng7929/article/details/85206877?utm_medium=distribute.pc_relevant.none-task-blog-title-2&spm=1001.2101.3001.4242 "參考地址七") 十一、劃重點 ~~~php /*$redis->psubscribe(array('__keyevent@'.$redis_db.'__:expired'), function ($redis, $pattern, $channel, $msg){ echo PHP_EOL; echo "Pattern: $pattern\n"; echo "Channel: $channel\n"; echo "Payload: $msg\n\n"; //................ });*/ ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "點擊并拖拽以移動") 點擊鏈接加入群聊【ThinkPHP56小功能】:[正在跳轉](https://jq.qq.com/?_wv=1027&k=Z0c641WP "正在跳轉")? ?
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看