PHP code example of mpbarlow / laravel-queue-debouncer
1. Go to this page and download the library: Download mpbarlow/laravel-queue-debouncer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mpbarlow / laravel-queue-debouncer example snippets
use App\Jobs\MyJob;
use Mpbarlow\LaravelQueueDebouncer\Debouncer;
class MyController
{
public function doTheThing(Debouncer $debouncer)
{
$debouncer->debounce(new MyJob(), 30);
// The class is also invokable:
$debouncer(new MyJob(), 30);
}
}
use App\Jobs\MyJob;
use Mpbarlow\LaravelQueueDebouncer\Facade\Debouncer;
Debouncer::debounce(new MyJob, 30);
use App\Jobs\MyJob;
debounce(new MyJob(), 30);
use Illuminate\Bus\Queueable;
use Illuminate\Foundation\Bus\Dispatchable;
use Mpbarlow\LaravelQueueDebouncer\Traits\Debounceable;
class MyJob {
use Debounceable, Dispatchable, Queueable;
}
MyJob::debounce('foo', 'bar', 'baz', 30);
class MyJob
{
use Dispatchable;
public function handle()
{
echo “Hello!\n”;
}
}
$job = new MyJob();
debounce($job, now()->addSeconds(5));
sleep(3);
debounce($job, now()->addSeconds(5));
sleep(3);
debounce($job, now()->addSeconds(5));