<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 隊列(Queueing) # 隊列(Queueing) Perform activities like process a video, resize images or send emails aren't suitable to be executedonline or in real time because it may slow the loading time of pages, impacting the user experience. The best solution here is implementing background jobs. A web application must put the jobinto a queue and wait that it will be processed. While you can find more sophisticated PHP extensions to address queueing in your applications like [RabbitMQ](http://pecl.php.net/package/amqp);Phalcon provides a client for [Beanstalk](http://www.igvita.com/2010/05/20/scalable-work-queues-with-beanstalk/), a job queueing backend inspired by [Memcache](http://memcached.org/).It’s simple, lightweight, and completely specialized on job queueing. ### 將任務加入隊列(Putting Jobs into the Queue) After connecting to Bens can insert as many jobs as required. The developer can define the messagestructure according to the needs of the application: ``` <pre class="calibre14">``` <?php // Connect to the queue $queue = new Phalcon\Queue\Beanstalk( array( 'host' => '192.168.0.21', 'port' => '11300' ) ); // Insert the job in the queue $queue->put( array('processVideo' => 4871) ); ``` ``` Available connection options are: OptionDescriptionDefaulthostIP where the beanstalk server is located127.0.0.1portConnection port11300In the above example we stored a message which will allow a background job to process a video.The message is stored in the queue immediately and does not have a certain time to life. Additional options as time to run, priority and delay could be passed as second parameter: ``` <pre class="calibre14">``` <?php // Insert the job in the queue with options $queue->put( array('processVideo' => 4871), array('priority' => 250, 'delay' => 10, 'ttr' => 3600) ); ``` ``` The following options are available: OptionDescriptionpriorityIt's an integer < 2\*\*32. Jobs with smaller priority values will be scheduled before jobs with larger priorities. The most urgent priority is 0; the least urgent priority is 4,294,967,295.delayIt's an integer number of seconds to wait before putting the job in the ready queue. The job will be in the “delayed” state during this time.ttrTime to run – is an integer number of seconds to allow a worker to run this job. This time is counted from the moment a worker reserves this job.Every job put into the queue returns a “job id” the developer can use to track the status of the job: ``` <pre class="calibre14">``` <?php $jobId = $queue->put( array('processVideo' => 4871) ); ``` ``` ### 檢索信息(Retrieving Messages) Once a job is placed into the queue, those messages can be consumed by a background job which have enough time to completethe task: ``` <pre class="calibre14">``` <?php while (($job = $queue->peekReady()) !== false) { $message = $job->getBody(); var_dump($message); $job->delete(); } ``` ``` Jobs must be removed from the queue to avoid double processing. If multiple background jobs workers are implemented,jobs must be “reserved” so other workers don't re-process them while other workers have them reserved: ``` <pre class="calibre14">``` <?php while (($job = $queue->reserve())) { $message = $job->getBody(); var_dump($message); $job->delete(); } ``` ``` Our client implement a basic set of the features provided by Beanstalkd but enough to allow you to build applicationsimplementing queues. | - [索引](# "總目錄") - [下一頁](# "數據庫抽象層(Database Abstraction Layer)") | - [上一頁](# "命令行應用(Command Line Applications)") |
                  <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>

                              哎呀哎呀视频在线观看