当前位置: 首页>>代码示例>>PHP>>正文


PHP Resque::size方法代码示例

本文整理汇总了PHP中Resque::size方法的典型用法代码示例。如果您正苦于以下问题:PHP Resque::size方法的具体用法?PHP Resque::size怎么用?PHP Resque::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Resque的用法示例。


在下文中一共展示了Resque::size方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: restGetQueueAdd

 public function restGetQueueAdd()
 {
     $this->changeViewModel('json');
     $queue = $this->params()->fromQuery('queue', 'default');
     $jobId = \Resque::enqueue($queue, 'Core\\Jobs\\TestJob', array('name' => $queue), true);
     return new JsonModel(array('id' => $jobId, 'size' => \Resque::size($queue)));
 }
开发者ID:ahyswang,项目名称:eva-engine,代码行数:7,代码来源:QueueController.php

示例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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-deploynaut,代码行数:12,代码来源:ResqueReport.php

示例3: cal_need_worker

 public static function cal_need_worker($queue)
 {
     $need_worker = 1;
     $pending_job_count = Resque::size($queue);
     // check if we need more workers
     $scaleSetting = !empty(Yii::app()->resque->scaleSetting) ? Yii::app()->resque->scaleSetting : self::$SCALE_SETTING;
     foreach ($scaleSetting as $job_count => $worker_count) {
         if ($pending_job_count > $job_count) {
             $need_worker = $worker_count;
         }
     }
     return $need_worker;
 }
开发者ID:timelessmemory,项目名称:uhkklp,代码行数:13,代码来源:ResqueScaler.php

示例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;
 }
开发者ID:neilmillard,项目名称:fxtrader,代码行数:18,代码来源:QueuesAction.php

示例5: 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());
开发者ID:viniciusthiengo,项目名称:modern-php-book,代码行数:28,代码来源:example_call_exec.php

示例6: 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);
 }
开发者ID:misterniall,项目名称:php-resque-ex,代码行数:11,代码来源:JobTest.php

示例7: 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);
 }
开发者ID:fahmiardi,项目名称:php-resque,代码行数:12,代码来源:JobTest.php

示例8: getSize

 public function getSize()
 {
     return \Resque::size($this->name);
 }
开发者ID:janiusus,项目名称:BCCResqueBundle,代码行数:4,代码来源:Queue.php

示例9: reQueueMovie

 /**
  * Queues a request for a Helioviewer.org movie
  */
 public function reQueueMovie($silent = false)
 {
     include_once HV_ROOT_DIR . '/../lib/alphaID/alphaID.php';
     include_once HV_ROOT_DIR . '/../lib/Resque.php';
     include_once HV_ROOT_DIR . '/../lib/Redisent/Redisent.php';
     include_once HV_ROOT_DIR . '/../src/Helper/HelioviewerLayers.php';
     include_once HV_ROOT_DIR . '/../src/Helper/HelioviewerEvents.php';
     include_once HV_ROOT_DIR . '/../src/Database/MovieDatabase.php';
     include_once HV_ROOT_DIR . '/../src/Database/ImgIndex.php';
     include_once HV_ROOT_DIR . '/../src/Movie/HelioviewerMovie.php';
     // Connect to redis
     $redis = new Redisent('localhost');
     // If the queue is currently full, don't process the request
     $queueSize = Resque::size(HV_MOVIE_QUEUE);
     if ($queueSize >= MOVIE_QUEUE_MAX_SIZE) {
         throw new Exception('Sorry, due to current high demand, we are currently unable ' . 'to process your request. Please try again later.', 40);
     }
     // Get current number of HV_MOVIE_QUEUE workers
     $workers = Resque::redis()->smembers('workers');
     $movieWorkers = array_filter($workers, function ($elem) {
         return strpos($elem, HV_MOVIE_QUEUE) !== false;
     });
     // Default options
     $defaults = array("format" => 'mp4', "force" => false);
     $options = array_replace($defaults, $this->_params);
     // Convert public alpha-numeric id to integer
     $movieId = alphaId($this->_params['id'], true, 5, HV_MOVIE_ID_PASS);
     $movieId = intval($movieId);
     if ($movieId <= 0) {
         throw new Exception('Value of movie "id" parameter is invalid.', 25);
     }
     // Check if movie exists on disk before re-queueing
     if ($options['force'] === false) {
         $helioviewerMovie = new Movie_HelioviewerMovie($this->_params['id'], $options['format']);
         $filepath = $helioviewerMovie->getFilepath();
         $path_parts = pathinfo($filepath);
         $extension = '.' . $path_parts['extension'];
         foreach (array('.mp4', '.flv', '.webm') as $ext) {
             $path = str_replace($extension, $ext, $filepath);
             if (@file_exists($path)) {
                 $url = str_replace(HV_CACHE_DIR, HV_CACHE_URL, $path);
                 throw new Exception('Movie file already exists: ' . $url, 44);
             }
         }
     }
     // Get movie metadata from database
     $movieDatabase = new Database_MovieDatabase();
     $movie = $movieDatabase->getMovieMetadata($movieId);
     // Check if movie is already in the queue (status=0)
     // or is already being processed (status=1) before re-queueing.
     // This prevents a spider, bot, or other automated user-agent
     // from stuffing the queue with redundant regeneration requests.
     // As such, the optional 'force' parameter will NOT override
     // this check.
     // However, if the movie status is considered stale, then
     // a Queued or Processing status is ignored and re-queueing
     // is allowed to proceed.
     $movieFormats = $movieDatabase->getMovieFormats($movieId);
     foreach ($movieFormats as $movieFormat) {
         $seconds_ago = time() - strtotime($movieFormat['modified']);
         $stale = 60 * 60 * 2;
         // 2 hours
         if ($movieFormat['status'] < 2 && $seconds_ago < $stale) {
             //throw new Exception('Movie can be regenerated only once every 2 hours', 47);
             //return;
         }
     }
     $numPixels = $movie['width'] * $movie['height'];
     $maxFrames = min($this->_getMaxFrames($queueSize), $movie['maxFrames']);
     // Create a connection to the database
     $db = new Database_ImgIndex();
     // Limit movies to three layers
     $layers = new Helper_HelioviewerLayers($movie['dataSourceString']);
     if ($layers->length() < 1 || $layers->length() > 3) {
         throw new Exception('Invalid layer choices! You must specify 1-3 comma-separated ' . 'layer names.', 22);
     }
     // Estimate the number of frames
     $numFrames = $this->_estimateNumFrames($db, $layers, $movie['startDate'], $movie['endDate']);
     $numFrames = min($numFrames, $maxFrames);
     // Estimate the time to create movie frames
     // @TODO 06/2012: Factor in total number of workers and number of
     //                workers that are currently available?
     $estBuildTime = $this->_estimateMovieBuildTime($movieDatabase, $numFrames, $numPixels, $options['format']);
     // If all workers are in use, increment and use estimated wait counter
     if ($queueSize + 1 >= sizeOf($movieWorkers)) {
         $eta = $redis->incrby('helioviewer:movie_queue_wait', $estBuildTime);
         $updateCounter = true;
     } else {
         // Otherwise simply use the time estimated for the single movie
         $eta = $estBuildTime;
         $updateCounter = false;
     }
     // Get datasource bitmask
     $bitmask = bindec($layers->getBitMask());
     $publicId = $this->_params['id'];
     // Queue movie request
     $args = array('movieId' => $publicId, 'eta' => $estBuildTime, 'format' => $options['format'], 'counter' => $updateCounter);
//.........这里部分代码省略.........
开发者ID:Helioviewer-Project,项目名称:api,代码行数:101,代码来源:Movies.php

示例10: status

 public function status()
 {
     // Load all the resque queue stats
     $stats["resqueStatus"] = array("defaultSize" => \Resque::size("default"), "importantSize" => \Resque::size("important"), "nowSize" => \Resque::size("now"), "turboSize" => \Resque::size("turbo"));
     render("information/status.twig", array("stats" => $stats));
 }
开发者ID:bllevy2,项目名称:projectRena,代码行数:6,代码来源:InformationController.php

示例11: 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);
 }
开发者ID:Rming,项目名称:novophp,代码行数:11,代码来源:JobTest.php

示例12: 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);
 }
开发者ID:HMAZonderland,项目名称:php-resque-ex,代码行数:11,代码来源:JobTest.php

示例13: getQueueSize

 /**
  * Get the number of jobs inside a queue.
  *
  * @param string $queue Queue name, e.g. 'default'.
  * @return int Number of jobs.
  * @see CakeResqueShell::clear()
  * @see CakeResqueShell::stats()
  * @codeCoverageIgnore
  */
 public static function getQueueSize($queue)
 {
     return Resque::size($queue);
 }
开发者ID:rchavik,项目名称:Cake-Resque,代码行数:13,代码来源:CakeResque.php

示例14: size

 public static function size($queue = 'default')
 {
     return \Resque::size($queue);
 }
开发者ID:bruensicke,项目名称:li3_resque,代码行数:4,代码来源:Resque.php


注:本文中的Resque::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。