I've got some time-consuming code that processes the results of a series of HTTP requests that I'd like to run in the background. I'm using a Redis store for managing the queue. Here's what I've tried:
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 */ },
]);
What shows up in the Redis queue store is a JSON
serialization of the $data
parameter:
{
"job": "FetchUrls",
"data": {
"urls": [
"http:\/\/one.com",
"http:\/\/two.com",
"http:\/\/three.com"
],
"complete": [],
"error": []
},
"id": "aAlkNM0ySLXcczlLYho19TlWYs9hStzl",
"attempts": 1
}
As you can see, the callbacks just show up as empty arrays in the queue store. I've never used the Queue class before and so I may be approaching this problem in the wrong way. I'm looking for a suggestion for the best way to work around this. Thanks!