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


PHP Resque::setBackend方法代码示例

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


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

示例1: init

 /**
  * Check that all needed and option params have been set
  *
  *
  */
 public function init()
 {
     // Ensure the composer autoloader is loaded so dependencies are loaded correctly
     require_once BASE_PATH . '/vendor/autoload.php';
     parent::init();
     $numWorkers = $this->request->getVar('count');
     if ($numWorkers > 1 && !function_exists('pcntl_fork')) {
         throw new Exception('This module need the pcntl PHP module');
     } else {
         if ($numWorkers) {
             $this->numWorkers = $numWorkers;
         }
     }
     if (php_sapi_name() !== 'cli') {
         echo 'The resque runner must be started in a CLI environment.';
         exit(1);
     }
     if (!$this->request->getVar('queue')) {
         echo "Set 'queue' parameter to containing the list of queues to work on.\n";
         exit(1);
     }
     $this->queue = $this->request->getVar('queue');
     if ($this->request->getVar('backend')) {
         Resque::setBackend($this->request->getVar('backend'));
     }
     $this->logger = new SSResqueLogger((bool) $this->request->getVar('verbose'));
 }
开发者ID:stojg,项目名称:silverstripe-resque,代码行数:32,代码来源:SSResqueRun.php

示例2: perform

 public function perform()
 {
     \Resque::setBackend('127.0.0.1:6379');
     \Resque::enqueue('default', 'ProofPilot\\Jobs\\VerificationNoticeJob', array());
     \Resque::enqueue('default', 'ProofPilot\\Jobs\\InterventionStartJob', array());
     \Resque::enqueue('default', 'ProofPilot\\Jobs\\GeneralNotificationInterventionJob', array());
 }
开发者ID:ddobei,项目名称:Fresque,代码行数:7,代码来源:GeneralNotificationInterventionJob.php

示例3: sendResetPasswordEmail

 public function sendResetPasswordEmail($args)
 {
     require NOVOPHP_VENDORS_DIR . '/PHPResque/lib/Resque.php';
     date_default_timezone_set('GMT');
     Resque::setBackend(RESQUE_SERVER_REDIS);
     $jobId = Resque::enqueue("email", "ResetPasswordEmail_Job", $args, true);
     return $jobId;
 }
开发者ID:Rming,项目名称:novophp,代码行数:8,代码来源:UsersHelper.php

示例4: testRedisExceptionsAreSurfaced

 /**
  * @expectedException Resque_RedisException
  */
 public function testRedisExceptionsAreSurfaced()
 {
     $mockCredis = $this->getMockBuilder('Credis_Client')->setMethods(['connect', '__call'])->getMock();
     $mockCredis->expects($this->any())->method('__call')->will($this->throwException(new CredisException('failure')));
     Resque::setBackend(function ($database) use($mockCredis) {
         return new Resque_Redis('localhost:6379', $database, $mockCredis);
     });
     Resque::redis()->ping();
 }
开发者ID:chrisboulton,项目名称:php-resque,代码行数:12,代码来源:RedisTest.php

示例5: setUp

 public function setUp()
 {
     $config = file_get_contents(REDIS_CONF);
     preg_match('#^\\s*port\\s+([0-9]+)#m', $config, $matches);
     $this->redis = new Credis_Client('localhost', $matches[1]);
     Resque::setBackend('redis://localhost:' . $matches[1]);
     // Flush redis
     $this->redis->flushAll();
 }
开发者ID:chrisboulton,项目名称:php-resque,代码行数:9,代码来源:TestCase.php

示例6: testRedisErrorThrowsExceptionOnJobCreation

 /**
  * @expectedException Resque_RedisException
  */
 public function testRedisErrorThrowsExceptionOnJobCreation()
 {
     $mockCredis = $this->getMockBuilder('Credis_Client')->setMethods(['connect', '__call'])->getMock();
     $mockCredis->expects($this->any())->method('__call')->will($this->throwException(new CredisException('failure')));
     Resque::setBackend(function ($database) use($mockCredis) {
         return new Resque_Redis('localhost:6379', $database, $mockCredis);
     });
     Resque::enqueue('jobs', 'This is a test');
 }
开发者ID:chrisboulton,项目名称:php-resque,代码行数:12,代码来源:JobTest.php

示例7: actionQueue

 public function actionQueue()
 {
     $class = Yii::$app->getRequest()->get('class');
     if (empty($class)) {
         exit('Empty Job Class !!!');
     }
     \Resque::setBackend('127.0.0.1:6379');
     $args = array('time' => time(), 'array' => array('test' => 'test'));
     $jobId = \Resque::enqueue('mail', '\\i\\models\\jobs\\' . $class, $args, true);
     $this->redirect(Url::toRoute(['queue/queues'], true));
 }
开发者ID:songhongyu,项目名称:datecenter,代码行数:11,代码来源:QueueController.php

示例8: configure

 /**
  * @param string $serverApiKey An API key that gives the application server authorized access to Google services.
  * @param string $sendJob Class name of the Job that extends DefaultSendJob.
  * @param mixed  $server Host/port combination separated by a colon, DSN-formatted URI, or a nested array of
  *                       servers with host/port pairs.
  * @param int    $database ID of Redis Database to select.
  * @param string $queueName Queue Name
  * @param mixed  $gcmUrl GCM URL.
  */
 public static function configure($serverApiKey, $sendJob, $server = 'localhost:6379', $database = 0, $queueName = null, $gcmUrl = false)
 {
     \Resque::setBackend($server, $database);
     self::$serverApiKey = $serverApiKey;
     self::$sendJob = $sendJob;
     if ($queueName) {
         self::$queueName = $queueName;
     }
     if ($gcmUrl) {
         self::$gcmUrl = $gcmUrl;
     }
 }
开发者ID:stevetauber,项目名称:php-gcm-queue,代码行数:21,代码来源:Client.php

示例9: initialize

 /**
  * initialize plugin
  *
  * @access public
  * @return void
  */
 public function initialize()
 {
     if ($this->configuration instanceof sfApplicationConfiguration) {
         $configCache = $this->configuration->getConfigCache();
         $configCache->registerConfigHandler(self::CONFIG_PATH, 'sfResqueConfigHandler');
         $config = (include $configCache->checkConfig(self::CONFIG_PATH));
     } else {
         $configPaths = $this->configuration->getConfigPaths(self::CONFIG_PATH);
         $config = sfResqueConfigHandler::getConfiguration($configPaths);
     }
     Resque::setBackend($config['server']);
 }
开发者ID:pmoutet,项目名称:navinum,代码行数:18,代码来源:sfResquePluginConfiguration.class.php

示例10: __construct

 public function __construct(array $options)
 {
     $this->defaultQueue = $options['default_queue'];
     $this->setKernelOptions($options['kernel_options']);
     $this->debug = $options['debug'];
     if (!$this->debug) {
         \Resque::setBackend("{$options['host']}:{$options['port']}");
         if (isset($options['prefix'])) {
             \Resque_Redis::prefix($options['prefix']);
         }
     }
     $this->trackStatus = $options['track_status'];
 }
开发者ID:mcfedr,项目名称:resque-queue-driver-bundle,代码行数:13,代码来源:ResqueQueueManager.php

示例11: __construct

 /**
  * @param string $host
  * @param int $port
  * @param array $kernelOptions
  * @param string $defaultQueue
  * @param bool $debug if debug is true then no calls to Resque will be made
  * @param boolean $trackStatus Set to true to be able to monitor the status of jobs
  */
 public function __construct($host, $port, $kernelOptions, $defaultQueue, $prefix, $debug, $trackStatus)
 {
     $this->defaultQueue = $defaultQueue;
     $this->setKernelOptions($kernelOptions);
     $this->debug = $debug;
     if (!$debug) {
         \Resque::setBackend("{$host}:{$port}");
         if ($prefix) {
             \Resque_Redis::prefix($prefix);
         }
     }
     $this->trackStatus = $trackStatus;
 }
开发者ID:mcfedr,项目名称:resque-bundle,代码行数:21,代码来源:ResqueManager.php

示例12: add

 public static function add($job_name, $queue_name, $args = array())
 {
     \Resque::setBackend('127.0.0.1:6379');
     if (strpos($queue_name, ':') !== false) {
         list($namespace, $queue_name) = explode(':', $queue_name);
         \Resque_Redis::prefix($namespace);
     }
     try {
         $klass = new \ReflectionClass($job_name);
         $jobId = \Resque::enqueue($queue_name, $klass->getName(), $args, true);
         return $jobId;
     } catch (\ReflectionException $rfe) {
         throw new \RuntimeException($rfe->getMessage());
     }
 }
开发者ID:hlegius,项目名称:PHPResqueBundle,代码行数:15,代码来源:Queue.php

示例13: __construct

 /**
  * Initialize the class and set its properties.
  *
  * @since    1.0.0
  * @param      string    $plugin_name       The name of this plugin.
  * @param      string    $version    The version of this plugin.
  */
 public function __construct($plugin_name, $version)
 {
     $this->plugin_name = $plugin_name;
     $this->version = $version;
     $this->redis = new Predis\Client(['scheme' => 'tcp', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'password' => REDIS_PASSWORD]);
     $this->blog_id = get_current_blog_id();
     if (function_exists('get_blog_details')) {
         $details = get_blog_details($this->blog_id, 'domain', false);
         $domain = $details->domain;
         $sub_domain = explode(".", $domain)[0];
         $this->sub_domain = $sub_domain;
     }
     Resque::setBackend(REDIS_HOST . ":" . REDIS_PORT, REDIS_DB);
     Resque_Event::listen('afterPerform', array('RooftopJob', 'afterPerform'));
 }
开发者ID:rooftopcms,项目名称:rooftop-queue-pusher,代码行数:22,代码来源:class-rooftop-queue-pusher-admin.php

示例14: init

 /**
  * Initializes the connection.
  */
 public function init()
 {
     parent::init();
     if (!class_exists('RResqueAutoloader', false)) {
         # Turn off our amazing library autoload
         spl_autoload_unregister(array('YiiBase', 'autoload'));
         # Include Autoloader library
         include dirname(__FILE__) . '/RResqueAutoloader.php';
         # Run request autoloader
         RResqueAutoloader::register();
         # Give back the power to Yii
         spl_autoload_register(array('YiiBase', 'autoload'));
     }
     Resque::setBackend($this->server . ':' . $this->port, $this->database, $this->password);
     if ($this->prefix) {
         Resque::redis()->prefix($this->prefix);
     }
 }
开发者ID:rolies106,项目名称:yii2resque,代码行数:21,代码来源:RResque.php

示例15: update

 public static function update($status, $to_job_id, $namespace)
 {
     \Resque::setBackend('127.0.0.1:6379');
     if (!empty($namespace)) {
         \Resque_Redis::prefix($namespace);
     }
     $job = new \Resque_Job_Status($to_job_id);
     if (!$job->get()) {
         throw new \RuntimeException("Job {$to_job_id} was not found");
     }
     $class = new \ReflectionObject($job);
     foreach ($class->getConstants() as $constant_value) {
         if ($constant_value == $status) {
             $job->update($status);
             return true;
         }
     }
     return false;
 }
开发者ID:hlegius,项目名称:PHPResqueBundle,代码行数:19,代码来源:Status.php


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