<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 功能強大 支持多語言、二開方便! 廣告
                # 接口 *Driver/QueueI.php* ``` <?php // +---------------------------------------------------------------------- // | QueueI.php // +---------------------------------------------------------------------- // | Description: queue interface // +---------------------------------------------------------------------- // | Time: 2018/12/19 上午11:17 // +---------------------------------------------------------------------- // | Author: Object,半醒的狐貍<2252390865@qq.com> // +---------------------------------------------------------------------- namespace Driver; interface QueueI { /** * @return array * 查詢tubes列表 * 一個系統需要多個隊列,它們可能分別用于存儲短信、郵件等,它們互相隔離。 */ public function tubes(): array; /** * @param Job $job * @return Job * 向隊列中存儲一個消息(任務) */ public function put(Job $job): Job; /** * @param string $tube 需要指定從哪個隊列接收任務 * @return Job * 從隊列接收一個消息(任務) */ public function reserve(string $tube): Job; /** * @param Job $job * @return bool * 刪除某個消息(任務) */ public function delete(Job $job): bool; /** * @param string $tube * @return array * 獲取某個隊列中的消息列表 */ public function jobs(string $tube): array; } ``` # 工具類 *Queue.php* ``` <?php // +---------------------------------------------------------------------- // | Queue.php // +---------------------------------------------------------------------- // | Description: 隊列工具 // +---------------------------------------------------------------------- // | Time: 2018/12/19 上午11:15 // +---------------------------------------------------------------------- // | Author: Object,半醒的狐貍<2252390865@qq.com> // +---------------------------------------------------------------------- class Queue { /** * @param string $driver * @param array $options * 初始化 */ public static function init($driver = 'Mysql',$options = []) { $class = "Driver\\$driver"; self::$driver = new $class($options); } public static function tubes(): array { return self::$driver->tubes(); } public static function put(Job $job): Job { return self::$driver->put($job); } public static function reserve(string $tube = 'default'): Job { return self::$driver->reserve($tube); } public static function jobs(string $tube = 'default'): array { return self::$driver->jobs($tube); } public static function delete(Job $job): bool { return self::$driver->delete($job); } } ``` # 數據對象 *Driver/Job.php* ``` <?php // +---------------------------------------------------------------------- // | Job.php // +---------------------------------------------------------------------- // | Description: 任務對象 // +---------------------------------------------------------------------- // | Time: 2018/12/19 下午3:19 // +---------------------------------------------------------------------- // | Author: Object,半醒的狐貍<2252390865@qq.com> // +---------------------------------------------------------------------- namespace Driver; class Job { public $id = null; public $tube; public $status; public $job_data; public $attempts; public $sort; public $reserved_at; public $available_at; public $created_at; public static $field = [ 'id', 'tube', 'status', 'job_data', 'attempts', 'sort', 'reserved_at', 'available_at', 'created_at', ]; public static $field_string = 'id,tube,status,job_data,attempts,sort,' . 'reserved_at,available_at,created_at'; public static function arr2job($jobs) { $real_jobs = []; foreach ($jobs as $v) { if (!is_array($v)) { $v = json_decode($v, true); } $real_jobs[] = new Job($v); } return $real_jobs; } public function __construct(array $data = []) { foreach ($data as $k => $v) { $this->$k = $v; } $this->created_at = time(); $this->available_at = $this->created_at; } public function isEmpty() { return $this->job_data ? false : true; } } ```
                  <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>

                              哎呀哎呀视频在线观看