本文整理汇总了PHP中Resque类的典型用法代码示例。如果您正苦于以下问题:PHP Resque类的具体用法?PHP Resque怎么用?PHP Resque使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Resque类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)));
}
示例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;
}
示例3: execute
/**
* Executes the cronjob task
*
* @param mixed $pid
* @param mixed $md5
*/
public static function execute($pid, $md5)
{
/** @var RenaApp $app */
$app = RenaApp::getInstance();
// Foreach page, throw the war url in question at the Resque task
$data = json_decode($app->cURL->getData("https://public-crest.eveonline.com/wars/", 0), true);
$pageCount = $data["pageCount"];
$currPage = 1;
while ($currPage <= $pageCount) {
// Get the data for the current page
$data = json_decode($app->cURL->getData("https://public-crest.eveonline.com/wars/?page=" . $currPage, 0), true);
foreach ($data["items"] as $war) {
// Figure out if it's already inserted, and if it has ended (or has zero kills)
$inserted = $app->wars->getWarByID($war["id"]);
// If nothing is inserted we'll update
if (empty($inserted)) {
\Resque::enqueue("default", "\\ProjectRena\\Task\\Resque\\populateWars", array("url" => $war["href"]));
}
$date = new DateTime("+36 hour");
$dateIn36Hours = $date->format("Y-m-d H:i:s");
if (!empty($inserted) && $inserted["lastUpdated"] > $dateIn36Hours) {
\Resque::enqueue("default", "\\ProjectRena\\Task\\Resque\\populateWars", array("url" => $war["href"]));
}
}
// Increment the currentPage variable, so we can fetch the next set of wars
$currPage++;
}
exit;
// Keep this at the bottom, to make sure the fork exits
}
示例4: dispatch
/**
* @param RemoteMessage $message
* @return void
*/
public function dispatch(RemoteMessage $message)
{
$this->events()->trigger(__FUNCTION__ . '.pre', $this, array('message' => $message));
$payload = array('message_class' => get_class($message), 'message_data' => $message->toArray());
$jobId = \Resque::enqueue($this->queue, $this->receiverJobClass, $payload, $this->trackStatus);
$this->events()->trigger(__FUNCTION__ . '.post', $this, array('message' => $message, 'jobId' => $jobId));
}
示例5: 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'));
}
示例6: 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());
}
示例7: 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);
}
示例8: perform
/**
* Performs the task, can access all $this->crap setup in setUp)
*/
public function perform()
{
$url = $this->args["url"];
$data = json_decode($this->app->cURL->getData($url, 0), true);
$warID = $data["id"];
$timeDeclared = $data["timeDeclared"];
$timeStarted = $data["timeStarted"];
$timeFinished = $data["timeFinished"];
$openForAllies = $data["openForAllies"];
$mutual = $data["mutual"];
$aggressor = $data["aggressor"]["id"];
$aggressorShipsKilled = $data["aggressor"]["shipsKilled"];
$aggressorISKKilled = $data["aggressor"]["iskKilled"];
$defender = $data["defender"]["id"];
$defenderShipsKilled = $data["defender"]["shipsKilled"];
$defenderISKKilled = $data["defender"]["iskKilled"];
$lastUpdated = date("Y-m-d H:i:s");
$this->app->wars->insertWar($warID, $timeDeclared, $timeStarted, $timeFinished, $openForAllies, $mutual, $aggressor, $aggressorShipsKilled, $aggressorISKKilled, $defender, $defenderShipsKilled, $defenderISKKilled);
$this->app->Db->execute("UPDATE wars SET lastUpdated = :lastUpdated WHERE warID = :warID", array(":lastUpdated" => $lastUpdated, ":warID" => $warID));
// Throw the killmail url after the killmail populate task
if ($aggressorShipsKilled > 0 || $defenderShipsKilled > 0) {
$killmailURL = $data["killmails"];
\Resque::enqueue("default", "\\ProjectRena\\Task\\Resque\\populateWarKillmails", array("url" => $killmailURL, "warID" => $warID));
}
}
示例9: control
public function control()
{
$this->redirectToSternIndiaEndpoint('forgot.php');
$config = Config::getInstance();
//$this->addToView('is_registration_open', $config->getValue('is_registration_open'));
// if (isset($_POST['email']) && $_POST['Submit'] == 'Send Reset') {
// /$_POST['email'] = 'prabhat@sternindia.com';
if (isset($_POST['email'])) {
$this->disableCaching();
$dao = DAOFactory::getDAO('UserDAO');
$user = $dao->getByEmail($_POST['email']);
if (isset($user)) {
$token = $user->setPasswordRecoveryToken();
$es = new ViewManager();
$es->caching = false;
//$es->assign('apptitle', $config->getValue('app_title_prefix')."ThinkUp" );
$es->assign('first_name', $user->first_name);
$es->assign('recovery_url', "session/reset.php?token={$token}");
$es->assign('application_url', Utils::getApplicationURL(false));
$es->assign('site_root_path', $config->getValue('site_root_path'));
$message = $es->fetch('_email.forgotpassword.tpl');
$subject = $config->getValue('app_title_prefix') . "Stern India Password Recovery";
//Will put the things in queue to mail the things.
Resque::enqueue('user_mail', 'Mailer', array($_POST['email'], $subject, $message));
$this->addToView('link_sent', true);
} else {
$this->addErrorMessage('Error: account does not exist.');
}
}
$this->setViewTemplate('Session/forgot.tpl');
return $this->generateView();
}
示例10: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
//Init rena
/** @var RenaApp $app */
$app = RenaApp::getInstance();
$run = true;
$oldKillID = 0;
do {
$p = \RedisQ\Action::listen("redisq.zkillboard.com");
if ($p["killID"] > $oldKillID) {
// Get the killmail data.
$k = $app->CrestFunctions->generateFromCREST($p);
// Poke statsd
$app->StatsD->increment("zKillboardReceived");
// Now lets make the json and hash
$json = json_encode($k, JSON_NUMERIC_CHECK);
$hash = $app->CrestFunctions->generateCRESTHash($k);
//$hash = hash("sha256", ":" . $k["killTime"] . ":" . $k["solarSystemID"] . ":" . $k["moonID"] . "::" . $k["victim"]["characterID"] . ":" . $k["victim"]["shipTypeID"] . ":" . $k["victim"]["damageTaken"] . ":");
// Lets insert the killmail!
$insert = $app->killmails->insertIntoKillmails($p["killID"], 0, $hash, "zkillboardRedisQ", $json);
// Upgrade it
if ($insert > 0) {
\Resque::enqueue("turbo", "\\ProjectRena\\Task\\Resque\\upgradeKillmail", array("killID" => $p["killID"]));
}
}
$oldKillID = $p["killID"];
} while ($run == true);
}
示例11: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
//Init rena
/** @var RenaApp $app */
$app = RenaApp::getInstance();
$app->StatsD->increment("ccpRequests");
$data = $app->EVEEVEAllianceList->getData();
if (isset($data["result"]["alliances"])) {
foreach ($data["result"]["alliances"] as $alliance) {
$output->writeln("Updating/Adding: " . $alliance["name"]);
// Update all the corporations in the alliance.. maybe we missed one?
foreach ($alliance["memberCorporations"] as $corporation) {
\Resque::enqueue("default", "\\ProjectRena\\Task\\Resque\\updateCorporation", array("corporationID" => $corporation["corporationID"]));
}
$allianceID = $alliance["allianceID"];
$allianceName = $alliance["name"];
$allianceTicker = $alliance["shortName"];
$memberCount = $alliance["memberCount"];
$executorCorporationID = $alliance["executorCorpID"];
$information = json_decode($app->cURL->getData("https://public-crest.eveonline.com/alliances/{$allianceID}/"), true)["description"];
$app->alliances->updateAllianceDetails($allianceID, $allianceName, $allianceTicker, $memberCount, $executorCorporationID, $information);
$app->alliances->setLastUpdated($allianceID, date("Y-m-d H:i:s"));
}
}
}
示例12: 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;
}
示例13: getRedis
private function getRedis()
{
$redis = \Resque::$redis;
if ($redis === null) {
$redis = \Resque::redis();
}
return $redis;
}
示例14: reserveBlocking
/**
* Find the next available job from the specified queues using blocking list pop
* and return an instance of Resque_Job for it.
*
* @param array $queues
* @param int $timeout
* @return null|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
*/
public static function reserveBlocking(array $queues, $timeout = null)
{
$item = Resque::blpop($queues, $timeout);
if (!is_array($item)) {
return false;
}
return new Resque_Job($item['queue'], $item['payload']);
}
示例15: send
/**
* Enqueue the message.
*
* @param \PhpGcmQueue\Message $message Message to send.
* @param \DateTime|boolean $delay When to send the message.
*/
public static function send(Message $message, $delay = false)
{
$args = ['serverApiKey' => self::$serverApiKey, 'gcmUrl' => self::$gcmUrl, 'message' => $message->toArray(), 'queueName' => self::$queueName, 'sendJob' => self::$sendJob];
if ($delay) {
$args['delay'] = $delay->format('U');
}
\Resque::enqueue(self::$queueName, self::$sendJob, $args);
}