本文整理汇总了PHP中Resque::queues方法的典型用法代码示例。如果您正苦于以下问题:PHP Resque::queues方法的具体用法?PHP Resque::queues怎么用?PHP Resque::queues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resque
的用法示例。
在下文中一共展示了Resque::queues方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restIndexQueue
public function restIndexQueue()
{
$config = Api::_()->getConfig();
$defaultQueues = $config['queue']['default_queues'];
$queues = array_merge($defaultQueues, \Resque::queues());
$queues = array_unique($queues);
foreach ($queues as $key => $queue) {
$queues[$key] = array('name' => $queue, 'size' => \Resque::size($queue));
}
$pslist = $this->getSystemProcessList('ps ux | grep "php ' . realpath(EVA_ROOT_PATH . '/workers') . '" | grep -v grep');
foreach ($queues as $key => $queue) {
$workerCount = 0;
foreach ($pslist as $psKey => $ps) {
$offset = strlen($ps['COMMAND']) - strlen($queue['name']);
if ($offset === strrpos($ps['COMMAND'], $queue['name'])) {
$workerCount++;
unset($pslist[$psKey]);
}
}
$queues[$key]['workers'] = $workerCount;
}
$publicWorkerCount = count($pslist);
$return = array('items' => $queues, 'publicWorkerCount' => $publicWorkerCount);
if ($this->params()->fromQuery('format') == 'json') {
$this->changeViewModel('json');
return new JsonModel($return);
}
return $return;
}
示例2: getQueues
/**
* @return ArrayList
*/
protected function getQueues()
{
$queues = Resque::queues();
$queueList = new ArrayList();
foreach ($queues as $idx => $queue) {
$queueList->push(new ResqueQueue(array('ID' => $idx + 1, 'Name' => $queue, 'Size' => Resque::size($queue))));
}
return $queueList;
}
示例3: getJobs
/**
* Get jobs for the given queue.
*
* @param string $queue The name of the queue or "*" for all queues
*
* @return array|\Resque_Job[]
*/
public function getJobs($queue = null)
{
if (!$queue || $queue === '*') {
$queues = \Resque::queues();
$jobs = array();
foreach ($queues as $queue) {
$jobs = array_merge($jobs, $this->getJobs($queue));
}
return $jobs;
}
return array_map(function ($job) use($queue) {
return new \Resque_Job($queue, json_decode($job, true));
}, \Resque::redis()->lrange('queue:' . $queue, 0, -1));
}
示例4: jobs
public function jobs(Request $request, Response $response, array $args)
{
$settings = loadsettings();
$REDIS_BACKEND = $settings['resque']['REDIS_BACKEND'];
if (!empty($REDIS_BACKEND)) {
\Resque::setBackend($REDIS_BACKEND);
}
$queues = [];
$queuenames = \Resque::queues();
sort($queuenames);
foreach ($queuenames as $queue) {
$size = \Resque::size($queue);
$queues[] = ['name' => $queue, 'size' => $size, 'jobs' => $this->peek($queue)];
}
$data['queues'] = $queues;
$this->view->render($response, 'queues.twig', $data);
return $response;
}
示例5: actionQueues
public function actionQueues()
{
$redisQueues = [];
$queues = \Resque::queues();
$redis = $this->getRedis();
// $queues = $redis->lrange('queue:default', 0,-1);
if ($queues) {
foreach ($queues as $queue) {
$key = 'queue:' . $queue;
$redisQueues[$queue] = $redis->lrange($key, 0, -1);
}
foreach ($redisQueues as $queue => $redisQueue) {
foreach ($redisQueue as $index => $que) {
$redisQueues[$queue][$index] = json_decode($que, true);
}
}
}
return $this->render('queues', ['queues' => $redisQueues]);
}
示例6: date_default_timezone_set
<?php
/**
* Created by PhpStorm.
* User: viniciusthiengo
* Date: 7/23/15
* Time: 10:50 AM
*/
require '../vendor/autoload.php';
require 'EchoData.php';
//include
date_default_timezone_set('GMT');
Resque::setBackend('127.0.0.1:6379');
$args = array('name' => 'Thiengo');
$jobId = Resque::enqueue('default', 'EchoData', $args, true);
echo "Queued job " . $jobId . "<br><br>";
$status = new Resque_Job_Status($jobId);
if (!$status->isTracking()) {
die("Resque is not tracking the status of this job.\n");
}
echo $status . '<br><br>';
$jobId = Resque::enqueue('cms26', 'EchoData2', $args);
//exec('echo "create-file.php" | atnow');
//exec('php "create-file.php" | atnow');
echo 'file has being created <br><br>';
//Resque::pop('notification');
echo Resque::size('default');
print_r(Resque::queues());
示例7: RedisUnavailable
/**
* Returns an error message if redis is unavailable
*
* @return string
*/
public static function RedisUnavailable()
{
try {
Resque::queues();
} catch (Exception $e) {
return $e->getMessage();
}
return '';
}
示例8: testJobWithNamespace
public function testJobWithNamespace()
{
Resque::setBackend(REDIS_HOST, REDIS_DATABASE, 'php');
$queue = 'jobs';
$payload = array('another_value');
Resque::enqueue($queue, 'Test_Job_With_TearDown', $payload);
$this->assertEquals(Resque::queues(), array('jobs'));
$this->assertEquals(Resque::size($queue), 1);
Resque::setBackend(REDIS_HOST, REDIS_DATABASE, REDIS_NAMESPACE);
$this->assertEquals(Resque::size($queue), 0);
}
示例9: queues
/**
* Return an array containing all of the queues that this worker should use
* when searching for jobs.
*
* If * is found in the list of queues, every queue will be searched in
* alphabetic order. (@see $fetch)
*
* @param boolean $fetch If true, and the queue is set to *, will fetch
* all queue names from redis.
* @return array Array of associated queues.
*/
public function queues($fetch = true)
{
if (!in_array('*', $this->queues) || $fetch == false) {
return $this->queues;
}
$queues = Resque::queues();
sort($queues);
return $queues;
}
示例10: testJobWithNamespace
public function testJobWithNamespace()
{
Resque_Redis::prefix('php');
$queue = 'jobs';
$payload = array('another_value');
Resque::enqueue($queue, 'Test_Job_With_TearDown', $payload);
$this->assertEquals(Resque::queues(), array('jobs'));
$this->assertEquals(Resque::size($queue), 1);
Resque_Redis::prefix('resque');
$this->assertEquals(Resque::size($queue), 0);
}
示例11: getQueues
public function getQueues()
{
return \array_map(function ($queue) {
return new Queue($queue);
}, \Resque::queues());
}
示例12: getQueues
/**
* Get the queues's names.
*
* @return array Array containing the queues' names.
* @see CakeResqueShell::clear()
* @see CakeResqueShell::stats()
* @codeCoverageIgnore
*/
public static function getQueues()
{
return Resque::queues();
}
示例13: queues
/**
* Return an array containing all of the queues that this worker should use
* when searching for jobs.
*
* If * is found in the list of queues, every queue will be searched in
* alphabetic order. (@see $fetch)
*
* @param boolean $fetch If true, and the queue is set to *, will fetch
* all queue names from redis.
* @return array Array of associated queues.
*/
public function queues($fetch = true)
{
if ($fetch == false) {
return $this->queues;
}
$user_queues = implode('|', $this->queues);
if (strpos($user_queues, '*') === FALSE) {
return $this->queues;
}
$queues = Resque::queues();
sort($queues);
if (in_array('*', $this->queues)) {
return $queues;
}
$matching_queues = [];
$user_queues_regexp = [];
foreach ($this->queues as $queue) {
if (strpos($queue, '*') === FALSE) {
$matching_queues[] = $queue;
} else {
foreach ($queues as $rqueue) {
if (fnmatch($queue, $rqueue)) {
$matching_queues[] = $rqueue;
}
}
}
}
return $matching_queues;
}