Delaying actions until times of lower traffic and completely offloading jobs to specialized servers are classic ways to scale. Also, the classic way to demonstrate how this works and the benefits is by sending an email. So here is the obligatory email example with the Crossley framework:
$oJob = new X_Scheduler_Job(X_Scheduler_Job::TYPE_PHP);
$oJob->setVariable('sSubject', 'A Test Email');
$oJob->setVariable('sBody', 'This is a test, Yo!');
Let me explain what is happening here. We are creating a PHP task by passing the PHP Type constant to the Scheduler Job class. We set the PHP script to ’email_script.php’. The contents of this script could be something as simple as the following:
$sHeaders = 'From: ' . $sFrom . "\r\n" .
'Reply-To: ' . $sFrom . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($sTo, $sSubject , $sBody, $sHeaders);
You notice the php variables used here, one way to set these values is via the setVariable() method of the X_Scheduler_Job object. These are then reset within it’s scope prior to executing the script.