本文整理汇总了PHP中Resque::dequeue方法的典型用法代码示例。如果您正苦于以下问题:PHP Resque::dequeue方法的具体用法?PHP Resque::dequeue怎么用?PHP Resque::dequeue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resque
的用法示例。
在下文中一共展示了Resque::dequeue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDequeueItemWithiWrongArg
public function testDequeueItemWithiWrongArg()
{
$queue = 'jobs';
$arg = array('foo' => 1, 'bar' => 2);
$arg2 = array('foo' => 2, 'bar' => 3);
Resque::enqueue($queue, 'Test_Job_Dequeue');
Resque::enqueue($queue, 'Test_Job_Dequeue', $arg);
$this->assertEquals(Resque::size($queue), 2);
$test = array('Test_Job_Dequeue' => $arg2);
$this->assertEquals(Resque::dequeue($queue, $test), 0);
$this->assertEquals(Resque::size($queue), 2);
}
示例2: die
<?php
if (empty($argv[1])) {
die('Specify the name of a job to remove. e.g, php queue.php PHP_Job');
}
require __DIR__ . '/init.php';
date_default_timezone_set('GMT');
Resque::setBackend('127.0.0.1:6379');
// You can also use a DSN-style format:
//Resque::setBackend('redis://user:pass@127.0.0.1:6379');
//Resque::setBackend('redis://user:pass@a.host.name:3432/2');
Resque::dequeue($argv[1], $argv[2]);
echo "Success";
示例3: testDequeueNonExistingItem2
public function testDequeueNonExistingItem2()
{
$queue = 'jobs';
Resque::enqueue($queue, 'Test_Job_Dequeue1');
Resque::enqueue($queue, 'Test_Job_Dequeue2');
Resque::enqueue($queue, 'Test_Job_Dequeue3');
$this->assertEquals(Resque::size($queue), 3);
$test = ['Test_Job_Dequeue4', 'Test_Job_Dequeue1'];
$this->assertEquals(Resque::dequeue($queue, $test), 1);
$this->assertEquals(Resque::size($queue), 2);
}
示例4: function
#!/usr/bin/php
<?php
$config = ['require_services' => ['credis', 'psr_log'], 'git_urls' => ['https://github.com/chrisboulton/php-resque.git' => 'php_resque/'], 'pear' => ['php_resque/lib/' => 'Resque'], 'example' => function () {
Resque::setBackend('localhost:6379');
class My_Job
{
public function perform()
{
echo $this->args['name'];
}
}
$statuses = [Resque_Job_Status::STATUS_WAITING => 'STATUS_WAITING', Resque_Job_Status::STATUS_RUNNING => 'STATUS_RUNNING', Resque_Job_Status::STATUS_FAILED => 'STATUS_FAILED', Resque_Job_Status::STATUS_COMPLETE => 'STATUS_COMPLETE'];
$args = ['name' => 'Chris'];
$token = Resque::enqueue('default', 'My_Job', $args, true);
echo $token . PHP_EOL;
$status = new Resque_Job_Status($token);
echo $statuses[$status->get()] . PHP_EOL;
Resque::dequeue('default', ['My_Job']);
$status = new Resque_Job_Status($token);
echo $statuses[$status->get()] . PHP_EOL;
}];
if ($return_config) {
return $config;
}
require_once __DIR__ . '/_yf_autoloader.php';
new yf_autoloader($config);
示例5: deleteJob
/**
* Delete a job based on job id or key, if worker_class is empty then it'll remove
* all jobs within the queue, if job_key is empty then it'll remove all jobs within
* provided queue and worker_class
*
* @param string $queue The name of the queue to place the job in.
* @param string $worker_class The name of the class that contains the code to execute the job.
* @param string $job_key Job key
*
* @return bool
*/
public function deleteJob($queue, $worker_class = null, $job_key = null)
{
if (!empty($job_key) && !empty($worker_class)) {
return Resque::dequeue($queue, array($worker_class => $job_key));
} else {
if (!empty($worker_class) && empty($job_key)) {
return Resque::dequeue($queue, array($worker_class));
} else {
return Resque::dequeue($queue);
}
}
// Remove all jobs inside queue
}