<?php include __DIR__ . '/../vendor/autoload.php'; // connect to database 0 on 127.0.0.1 $redis = new Predis\Client('tcp://127.0.0.1:6379/0'); // Instantiate a new client $client = new \SidekiqJob\Client($redis); // schedule in exactly one hour (requires epoch time with microseconds) $time = microtime(true) + 60 * 60; // push a job with one argument $id = $client->schedule($time, 'ProcessImage', [['url' => 'http://i.imgur.com/hlAsa4k.jpg'], false]); var_dump(sprintf('Scheduled job with id %s', $id));
<?php include __DIR__ . '/../vendor/autoload.php'; function _print($id, $retry) { var_dump(sprintf('Pushed job with id %s and retry:%d', $id, $retry)); } // connect to database 0 on 127.0.0.1 $redis = new Predis\Client('tcp://127.0.0.1:6379/0'); // Instantiate a new client $client = new \SidekiqJob\Client($redis); // push a job with three arguments - args array needs to be sequential (not associative) $args = [['url' => 'http://i.imgur.com/hlAsa4k.jpg'], true, 70]; $id = $client->push('ProcessImage', $args, true); _print($id, true); $id = $client->push('ProcessImage', $args, false); _print($id, false);
<?php include __DIR__ . '/../vendor/autoload.php'; // connect to database 0 on 127.0.0.1 $redis = new Predis\Client('tcp://127.0.0.1:6379/0'); // Instantiate a new client $client = new \SidekiqJob\Client($redis); // define jobs with args $jobs = [['class' => 'ProcessImage', 'args' => [['url' => 'http://i.imgur.com/hlAsa4k.jpg'], true, 12]], ['class' => 'ProcessImage', 'args' => [['url' => 'http://i.imgur.com/hlAsa4k.jpg'], true, null]], ['class' => 'ProcessImage', 'args' => [['url' => 'http://i.imgur.com/hlAsa4k.jpg']], 'at' => microtime(true) + 60 * 6, 'retry' => false]]; // push jobs to a different queue $ids = $client->pushBulk($jobs, 'images'); var_dump('Pushed job with ids:', $ids);
<?php include __DIR__ . '/../vendor/autoload.php'; // connect to database 0 on 127.0.0.1 $redis = new Predis\Client(['host' => 'localhost', 'port' => '6379', 'database' => 0]); // Instantiate a new client within 'users' namespace $client = new \SidekiqJob\Client($redis, 'users'); // push a job with three arguments - args array needs to be sequential (not associative) $args = [['url' => 'http://i.imgur.com/hlAsa4k.jpg'], true, 70]; $id = $client->push('ProcessImage', $args); var_dump(sprintf('Pushed job with id %s', $id));