Created
February 27, 2014 21:14
-
-
Save daum/9259700 to your computer and use it in GitHub Desktop.
Gearman Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// In controller | |
public function triggerSendNotificationsAction(Request $request) | |
{ | |
// Code to get that user triggered a bunch of notifications to an array of user ids. | |
$userIds = array(.......); | |
$message = 'some message from the frontend user'; | |
//Get Gearman and tell it to run in the background a 'job' | |
$this->get('gearman')->doBackgroundJob('MyDemoBundleWorker~sendNotificationsToUsers', | |
json_encode(array('user_ids'=>$userIds,'message'=>$message))); | |
return $this->renderText('Your notifications are being sent now!'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment