久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <bdo id='O6oyO'></bdo><ul id='O6oyO'></ul>

    1. <i id='O6oyO'><tr id='O6oyO'><dt id='O6oyO'><q id='O6oyO'><span id='O6oyO'><b id='O6oyO'><form id='O6oyO'><ins id='O6oyO'></ins><ul id='O6oyO'></ul><sub id='O6oyO'></sub></form><legend id='O6oyO'></legend><bdo id='O6oyO'><pre id='O6oyO'><center id='O6oyO'></center></pre></bdo></b><th id='O6oyO'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='O6oyO'><tfoot id='O6oyO'></tfoot><dl id='O6oyO'><fieldset id='O6oyO'></fieldset></dl></div>

      <small id='O6oyO'></small><noframes id='O6oyO'>

      <tfoot id='O6oyO'></tfoot>
    2. <legend id='O6oyO'><style id='O6oyO'><dir id='O6oyO'><q id='O6oyO'></q></dir></style></legend>

      在 Laravel 中取消作業

      Cancel Jobs In Laravel(在 Laravel 中取消作業)
        <bdo id='0WJkK'></bdo><ul id='0WJkK'></ul>

        • <legend id='0WJkK'><style id='0WJkK'><dir id='0WJkK'><q id='0WJkK'></q></dir></style></legend><tfoot id='0WJkK'></tfoot>
            <tbody id='0WJkK'></tbody>
            • <i id='0WJkK'><tr id='0WJkK'><dt id='0WJkK'><q id='0WJkK'><span id='0WJkK'><b id='0WJkK'><form id='0WJkK'><ins id='0WJkK'></ins><ul id='0WJkK'></ul><sub id='0WJkK'></sub></form><legend id='0WJkK'></legend><bdo id='0WJkK'><pre id='0WJkK'><center id='0WJkK'></center></pre></bdo></b><th id='0WJkK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0WJkK'><tfoot id='0WJkK'></tfoot><dl id='0WJkK'><fieldset id='0WJkK'></fieldset></dl></div>

                <small id='0WJkK'></small><noframes id='0WJkK'>

              1. 本文介紹了在 Laravel 中取消作業的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                如果我調用以下內容:

                return AdventureJob::dispatch($event->character->refresh(), $event->adventure, $event->levelsAtATime)->delay($timeTillFinished);
                

                這將創建一個延遲 x 分鐘的作業.我的作業都是通過redis處理的,有沒有辦法獲取這個特定的作業或者從隊列中刪除這個特定的作業?

                This will then create a job thats delayed x minutes. my jobs are all processed through redis, is there a way to then get this specific job or delete this specific job from the queue?

                人們談論 php artisan 命令然后刪除所有作業,這不是我想要的我想獲取有關此作業的某種信息(作業 ID?或隊列 ID?Redis ID?)然后存儲在數據庫中如果玩家然后取消冒險,我可以使用它在隊列中找到這個作業并刪除它,假設它沒有運行.

                People talk about php artisan commands to then delete all jobs, thats not what I want I want to get some kind of information (Job ID? or queue ID? Redis ID?) about this job to then store in the database so that if the player then cancels the adventure, I can use that to find this job on the queue and delete it, assuming it's not running.

                推薦答案

                沒有直接或簡單的方法來做到這一點.延遲的作業保存在 sorted set 中作為待處理時間作為 score 和作業負載作為 value.

                There is no direct or easy way to do it. The delayed jobs are kept in sorted sets as to-be-processed time as score and job payload as the value.

                有幾種方法可以從已排序的集合中移除元素(其中大多數需要一些努力,具體取決于延遲隊列的大小),例如

                There are several ways to remove an element from the sorted sets(most of them require some efforts depending on the size of the delayed queue) such as

                • 你得到了精確的"分派作業的有效負載,然后使用 ZREM 將其刪除.這很困難,因為對象(具有所有參數的作業的序列化版本)可能很大,而且您無法創建精確"的對象.工作,因為它有一個唯一的標識符.您可以使用 ZRANGEBYSCORE 和 WITHSCORES 獲取它的列表.它將為您提供帶有分數的工作列表.您可以使用分數來識別被延遲的工作.獲取值(序列化的有效負載)然后使用 ZREM.
                • 如果在特定時間只有一項作業要處理,您可以使用 ZREMRANGEBYSCORE使用處理時間.如果恰好在那個時間有 n 個作業要處理,那么其他作業也可以刪除,因為 ZREMRANGEBYSCORE 需要時間間隔.
                • 您可以嘗試使用 ZSCAN 掃描整個延遲列表(帶分頁)并找到作業的分數和標識符,然后使用帶有標識符的 ZREMRANGEBYLEX 將其刪除.
                • 另一種方法是在 handle 方法的開頭放置一個取消條件.這個需要應用層開發.每當您將作業推送到隊列時,您都會向作業發送一個標識符,在 Redis 中也放置相同的標識符(您可以理解)(EXPIRE 大于延遲時間).當你想取消它時,然后從Redis中刪除它.在 handle 方法內部檢查給定的標識符是否存在于 Redis 中,如果不存在則從代碼塊提前返回.
                • You get the "exact" payload of the dispatched job and then use ZREM to remove it. It is hard because the object(serialized version of the job with all the parameters) can be huge and you can't create the "exact" job because it has a unique identifier. You can get the list of it with ZRANGEBYSCORE and with WITHSCORES. It will give you the list of jobs with their scores. You can use score to identify to be delayed job. Get the value(serialized payload) then use ZREM.
                • If there is only one job to be processed at a specific time you, may use ZREMRANGEBYSCORE with using the processed time. If there are n jobs to be processed exactly that time then other jobs can be deleted too since ZREMRANGEBYSCORE takes time interval.
                • You may try to use ZSCAN to scan the whole delayed list(with pagination) and find the score and identifier of the job, and then use ZREMRANGEBYLEX with the identifier to remove it.
                • Another way could be putting a cancellation condition at the beginning of handle method. This one requires application layer development. Whenever you push a job to the queue you send an identifier to the job, put same identifier(that you can understand) in Redis too(with EXPIRE greater than the delayed time). When you want to cancel it, then delete it from the Redis. Inside the handle method check whether the given identifier exists in Redis, if not early return from the code block.

                這篇關于在 Laravel 中取消作業的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                PHP PDO ODBC connection(PHP PDO ODBC 連接)
                Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
              2. <small id='JDAqB'></small><noframes id='JDAqB'>

                <legend id='JDAqB'><style id='JDAqB'><dir id='JDAqB'><q id='JDAqB'></q></dir></style></legend>

                  <tbody id='JDAqB'></tbody>

                  <i id='JDAqB'><tr id='JDAqB'><dt id='JDAqB'><q id='JDAqB'><span id='JDAqB'><b id='JDAqB'><form id='JDAqB'><ins id='JDAqB'></ins><ul id='JDAqB'></ul><sub id='JDAqB'></sub></form><legend id='JDAqB'></legend><bdo id='JDAqB'><pre id='JDAqB'><center id='JDAqB'></center></pre></bdo></b><th id='JDAqB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JDAqB'><tfoot id='JDAqB'></tfoot><dl id='JDAqB'><fieldset id='JDAqB'></fieldset></dl></div>

                      • <bdo id='JDAqB'></bdo><ul id='JDAqB'></ul>

                        <tfoot id='JDAqB'></tfoot>
                          主站蜘蛛池模板: 精品一区二区三区免费视频 | 天堂一区二区三区 | 国产精品美女久久久久久免费 | 欧美一级欧美三级在线观看 | 国产高清免费在线 | 欧美久久视频 | 国产一区在线免费 | 综合亚洲视频 | 国产操操操| xx视频在线 | 做a视频| 国产成人综合av | 国精产品一区二区三区 | 91高清在线视频 | 日本中文字幕在线视频 | 成人在线免费观看视频 | 成人精品一区二区三区 | 欧美一区二区三区精品 | 日韩欧美国产一区二区三区 | 五月激情婷婷网 | 日韩中文字幕一区 | 欧美高清视频在线观看 | 国产精品亚洲成在人线 | 每日更新av| 国产一二区免费视频 | 欧美日韩亚洲国产 | 亚洲 中文 欧美 日韩 在线观看 | 色婷婷综合久久久中字幕精品久久 | 男女网站免费 | 免费观看av | 日操操| 久久天天躁狠狠躁夜夜躁2014 | 亚洲一区综合 | 国产性生活一级片 | 一级黄色影片在线观看 | 久久久精品在线 | 一二三区av | 国产电影一区二区在线观看 | 婷婷激情在线 | 91影院 | 精品国产一区二区三区性色av |