Reputation: 15091
I am trying to delay the execution of a script by a few seconds after it processes say 200 records using Laravel's chunk method. Here's what I've right now. Should I put a counter somewhere? But then that will not work I believe, are there other techniques?
Article::chunk(200, function ($articles)
{
foreach ($articles as $article)
{
}
});
Thanks to WereWolf, it worked. Can't believe it was so simple.
[2014-08-27 07:18:23] local.INFO: Article metrics:198 [] []
[2014-08-27 07:18:24] local.INFO: Article metrics:199 [] []
[2014-08-27 07:18:24] local.INFO: Article metrics:200 [] []
[2014-08-27 07:18:30] local.INFO: Article metrics:201 [] []
[2014-08-27 07:18:34] local.INFO: Article metrics:202 [] []
Upvotes: 5
Views: 12947