Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
W
wiki-php
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • 互联网应用开发
  • wiki-php
  • Wiki
  • php job queue

Last edited by 王常春 Nov 22, 2019
Page history
This is an old version of this page. You can view the most recent version or browse the history.

php job queue

php多任务并发处理队列

PHP并发队列原理

首先在php下编写job,在app-job\bin\目录下实现对应的job类,然后在需要使用的地方将任务依次加入队列。python脚本会依次从队列里面取出任务去执行。

Job类

参考Bin_Wiki_UpdateCertWebsiteExpire.注意这里它即实现了生产者也实现了消费者逻辑,start_general_queue函数将需要执行的任务依次加入队列,add_queue则依次消费完成任务。

任务加入队列

任务加入队列,就是加入redis的一个list队列,此处可以使用GlobalFun::add_python_job($job_class, $args=[], $queue_name='default', $is_urgent=false). 参数 | 类型 | 说明 --- | --- | --- $job_class | string | 任务执行类名称,如Bin_Wiki_UpdateCertWebsiteExpire

Clone repository
  • 360safeguardnativeapi
  • all new classmate
  • bind phone
  • code standard
  • deploy_sys
  • edit common
  • edit master
  • envrioment
  • find psw
  • front new classmate
  • front statck
  • git
  • Home
  • idcard md5
  • ide
View All Pages