You are here

function cron_example_cron_queue_info in Examples for Developers 7

Implements hook_cron_queue_info().

hook_cron_queue_info() and family are new since Drupal 7, and allow any process to add work to the queue to be acted on when cron runs. Queues are described and worker callbacks are provided, and then only the worker callback needs to be implemented.

All the details of queue use are done by the cron_queue implementation, so one doesn't need to know much about DrupalQueue().

See also

queue_example.module

Related topics

File

cron_example/cron_example.module, line 202
Demonstrates use of the Cron API in Drupal - hook_cron()

Code

function cron_example_cron_queue_info() {
  $queues['cron_example_queue_1'] = array(
    'worker callback' => 'cron_example_queue_1_worker',
    // One second max runtime per cron run.
    'time' => 1,
  );
  $queues['cron_example_queue_2'] = array(
    'worker callback' => 'cron_example_queue_2_worker',
    'time' => 10,
  );
  return $queues;
}