我有一些耗時的代碼來處理一系列希望運行的HTTP請求的結果的背景。我正在使用Redis存儲管理隊列。以下是我已經試過:有沒有辦法將回調作爲數據參數傳遞給Laravel 4.2隊列:: push()
Queue::push('FetchUrls', [
'urls' => [ 'http://one.com', 'http://two.com', 'http://three.com' ],
'complete' => function($response) { /* process data returned by URL here */ },
'error' => function($error ) { /* process HTTP errors here */ },
]);
什麼Redis的隊列存儲顯示出來是JSON
系列化$data
參數:
{
"job": "FetchUrls",
"data": {
"urls": [
"http:\/\/one.com",
"http:\/\/two.com",
"http:\/\/three.com"
],
"complete": [],
"error": []
},
"id": "aAlkNM0ySLXcczlLYho19TlWYs9hStzl",
"attempts": 1
}
正如你所看到的,回調只是顯示爲空隊列存儲中的數組。我以前從未使用Queue類,所以我可能以錯誤的方式處理這個問題。我正在尋找一個解決此問題的最佳方法的建議。謝謝!
謝謝!這是我正在尋找的解決方案! – morphatic 2014-09-22 05:56:21