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


PHP Resque::redis方法代码示例

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


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

示例1: setBackend

	public static function setBackend($server)
	{
		list($host, $port) = explode(':', $server);

		require_once dirname(__FILE__).'/Resque/Redis.php';
		self::$redis = new Resque_Redis($host, $port);
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:7,代码来源:Resque.php

示例2: redis

 /**
  * Return an instance of the Resque_Redis class instantiated for Resque.
  *
  * @return Resque_Redis Instance of Resque_Redis.
  */
 public static function redis()
 {
     // Detect when the PID of the current process has changed (from a fork, etc)
     // and force a reconnect to redis.
     $pid = getmypid();
     if (self::$pid !== $pid) {
         self::$redis = null;
         self::$pid = $pid;
     }
     if (!is_null(self::$redis)) {
         return self::$redis;
     }
     $server = self::$redisServer;
     if (empty($server)) {
         $server = 'localhost:6379';
     }
     if (is_array($server)) {
         require_once dirname(__FILE__) . '/Resque/RedisCluster.php';
         self::$redis = new Resque_RedisCluster($server);
     } else {
         if (strpos($server, 'unix:') === false) {
             list($host, $port) = explode(':', $server);
         } else {
             $host = $server;
             $port = null;
         }
         require_once dirname(__FILE__) . '/Resque/Redis.php';
         $redisInstance = new Resque_Redis($host, $port);
         $redisInstance->prefix(self::$namespace);
         self::$redis = $redisInstance;
     }
     self::$redis->select(self::$redisDatabase);
     return self::$redis;
 }
开发者ID:klimis,项目名称:php-edge,代码行数:39,代码来源:Resque.php

示例3: getRedis

 private function getRedis()
 {
     $redis = \Resque::$redis;
     if ($redis === null) {
         $redis = \Resque::redis();
     }
     return $redis;
 }
开发者ID:songhongyu,项目名称:datecenter,代码行数:8,代码来源:QueueController.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: jobs

 /**
  * @return Job[]
  */
 public function jobs()
 {
     $result = \Resque::redis()->lrange('queue:' . $this->name, 0, -1);
     $jobs = [];
     foreach ($result as $job) {
         $jobs[] = (new \Resque_Job($this->name, \json_decode($job, true)))->getInstance();
     }
     return $jobs;
 }
开发者ID:hlgrrnhrdt,项目名称:laravel-resque,代码行数:12,代码来源:Queue.php

示例6: getJobs

 public function getJobs($start = 0, $stop = -1)
 {
     $jobs = \Resque::redis()->lrange('queue:' . $this->name, $start, $stop);
     $result = array();
     foreach ($jobs as $job) {
         $job = new \Resque_Job($this->name, \json_decode($job, true));
         $result[] = $job->getInstance();
     }
     return $result;
 }
开发者ID:janiusus,项目名称:BCCResqueBundle,代码行数:10,代码来源:Queue.php

示例7: peek

 /**
  * Peek
  *
  * @param string $queue The name of the queue
  * @param integer $start
  * @param integer $count
  *
  * @return array List of jobs
  *
  */
 public static function peek($queue, $start = 0, $count = 1000)
 {
     $jobs = \Resque::redis()->lrange('queue:' . $queue, $start, $count);
     $curr_jobs = array();
     if (is_array($jobs)) {
         foreach ($jobs as $job) {
             $curr_jobs[] = json_decode($job, TRUE);
         }
     }
     return $curr_jobs;
 }
开发者ID:neilmillard,项目名称:fxtrader,代码行数:21,代码来源:QueuesAction.php

示例8: requeue

 public static function requeue($id)
 {
     //        item = all(id)
     //        item['retried_at'] = Time.now.rfc2822
     //        Resque.redis.lset(:failed, id, Resque.encode(item))
     //        Job.create(item['queue'], item['payload']['class'], *item['payload']['args'])
     $item = current(self::all($id, 1));
     $item->retried_at = strftime('%a %b %d %H:%M:%S %Z %Y');
     $data = json_encode($item);
     \Resque::redis()->lset('failed', $id, $data);
     \Resque::enqueue($item->queue, $item->payload->class, (array) $item->payload->args[0]);
 }
开发者ID:geoffreytran,项目名称:zym,代码行数:12,代码来源:Redis.php

示例9: setBackend

 /**
  * Given a host/port combination separated by a colon, set it as
  * the redis server that Resque will talk to.
  *
  * @param mixed $server Host/port combination separated by a colon, or
  * a nested array of servers with host/port pairs.
  */
 public static function setBackend($server, $database = 0)
 {
     if (is_array($server)) {
         require_once dirname(__FILE__) . '/Resque/RedisCluster.php';
         self::$redis = new Resque_RedisCluster($server);
     } else {
         list($host, $port) = explode(':', $server);
         require_once dirname(__FILE__) . '/Resque/Redis.php';
         self::$redis = new Resque_Redis($host, $port);
     }
     self::redis()->select($database);
 }
开发者ID:Rming,项目名称:novophp,代码行数:19,代码来源:Resque.php

示例10: __construct

 /**
  * Initialize a failed job class and save it (where appropriate).
  *
  * @param object $payload Object containing details of the failed job.
  * @param object $exception Instance of the exception that was thrown by the failed job.
  * @param object $worker Instance of Resque_Worker that received the job.
  * @param string $queue The name of the queue the job was fetched from.
  */
 public function __construct($payload, $exception, $worker, $queue)
 {
     $data = new stdClass();
     $data->failed_at = strftime('%a %b %d %H:%M:%S %Z %Y');
     $data->payload = $payload;
     $data->exception = get_class($exception);
     $data->error = $exception->getMessage();
     $data->backtrace = explode("\n", $exception->getTraceAsString());
     $data->worker = (string) $worker;
     $data->queue = $queue;
     $data = json_encode($data);
     Resque::redis()->rpush('failed', $data);
 }
开发者ID:jacques,项目名称:php-resque,代码行数:21,代码来源:Redis.php

示例11: fork

 /**
  * fork() helper method for php-resque that handles issues PHP socket
  * and phpredis have with passing around sockets between child/parent
  * processes.
  *
  * Will close connection to Redis before forking.
  *
  * @return int Return vars as per pcntl_fork()
  */
 public static function fork()
 {
     if (!function_exists('pcntl_fork')) {
         return -1;
     }
     // Close the connection to Redis before forking.
     // This is a workaround for issues phpredis has.
     self::$redis = null;
     $pid = pcntl_fork();
     if ($pid === -1) {
         throw new RuntimeException('Unable to fork child worker.');
     }
     return $pid;
 }
开发者ID:rolies106,项目名称:yii2resque,代码行数:23,代码来源:Resque.php

示例12: startup

 /**
  * Startup callback.
  *
  * Initializes defaults.
  */
 public function startup()
 {
     $resqueLib = Configure::read('CakeResque.Resque.lib');
     $schedulerLib = Configure::read('CakeResque.Scheduler.lib');
     $pluginVendorPath = CakePlugin::path('CakeResque') . 'vendor' . DS;
     if (substr($resqueLib, 0, 1) !== '/') {
         $resqueLib = $pluginVendorPath . $resqueLib;
     }
     $this->_resqueLibrary = realpath($resqueLib) . DS;
     if (substr($schedulerLib, 0, 1) !== '/') {
         $schedulerLib = $pluginVendorPath . $schedulerLib;
     }
     $this->_resqueSchedulerLibrary = realpath($schedulerLib) . DS;
     $this->ResqueStatus = new ResqueStatus\ResqueStatus(Resque::redis());
     $this->stdout->styles('success', array('text' => 'green'));
     $this->stdout->styles('bold', array('bold' => true));
 }
开发者ID:rchavik,项目名称:Cake-Resque,代码行数:22,代码来源:CakeResqueShell.php

示例13: getJobs

 protected function getJobs()
 {
     $jobs = new ArrayList();
     $resqueJobs = Resque::redis()->lrange('queue:' . $this->Name, 0, -1);
     if (!$resqueJobs) {
         $jobs->push(new ResqueJob(array('Name' => 'null', 'Value' => 'null')));
         return $jobs;
     }
     foreach ($resqueJobs as $idx => $job) {
         $stdClass = json_decode($job);
         if ($stdClass->class === 'CapistranoDeploy' || $stdClass->class === 'DeployJob') {
             $jobs->push(new ResqueJob(array('Name' => $stdClass->class, 'Value' => $stdClass->args[0]->projectName . ':' . $stdClass->args[0]->environment . ' - ' . $stdClass->args[0]->sha)));
         } else {
             $jobs->push(new ResqueJob(array('Name' => $stdClass->class, 'Value' => var_export($stdClass->args[0], true))));
         }
     }
     return $jobs;
 }
开发者ID:adrexia,项目名称:deploynaut,代码行数:18,代码来源:ResqueQueue.php

示例14: get_all_workers

 public static function get_all_workers($queue = NULL)
 {
     $ret = array();
     $workers = Resque::redis()->smembers('workers');
     if (!is_array($workers)) {
         $workers = array();
     }
     foreach ($workers as $workerId) {
         $worker_data = explode(':', $workerId, 4);
         $worker = array();
         $worker['hostname'] = $worker_data[0];
         $worker['queues'] = explode(',', $worker_data[2]);
         $worker['pid'] = $worker_data[1];
         $worker['programname'] = $worker_data[3];
         $worker['workerId'] = $workerId;
         if ($queue && (in_array($queue, $worker['queues']) || in_array("*", $worker['queues'])) || !$queue) {
             $ret[] = $worker;
         }
     }
     return $ret;
 }
开发者ID:timelessmemory,项目名称:uhkklp,代码行数:21,代码来源:ResqueScaler.php

示例15: workerRemoveDead

 public function workerRemoveDead($user)
 {
     $this->ResqueStatus = new ResqueStatus\ResqueStatus(Resque::redis());
     $workers = $this->ResqueStatus->getWorkers();
     $this->Log = ClassRegistry::init('Log');
     if (function_exists('posix_getpwuid')) {
         $currentUser = posix_getpwuid(posix_geteuid());
         $currentUser = $currentUser['name'];
     } else {
         $currentUser = trim(shell_exec('whoami'));
     }
     foreach ($workers as $pid => $worker) {
         if (!is_numeric($pid)) {
             throw new MethodNotAllowedException('Non numeric PID found!');
         }
         $pidTest = substr_count(trim(shell_exec('ps -p ' . $pid)), PHP_EOL) > 0 ? true : false;
         if ($worker['user'] == $currentUser && !$pidTest) {
             $this->ResqueStatus->removeWorker($pid);
             $this->Log->create();
             $this->Log->save(array('org' => $user['org'], 'model' => 'User', 'model_id' => $user['id'], 'email' => $user['email'], 'action' => 'remove_dead_workers', 'user_id' => $user['id'], 'title' => 'Removing a dead worker.', 'change' => 'Removind dead worker data. Worker was of type ' . $worker['queue'] . ' with pid ' . $pid));
         }
     }
 }
开发者ID:firebitsbr,项目名称:MISP,代码行数:23,代码来源:Server.php


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