3 * Table Definition for queue_item
5 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
7 class Queue_item extends Memcached_DataObject
10 /* the code below is auto generated do not remove the above tag */
12 public $__table = 'queue_item'; // table name
13 public $id; // int(4) primary_key not_null
14 public $frame; // blob not_null
15 public $created; // datetime() not_null
16 public $claimed; // datetime()
19 function staticGet($k,$v=null)
20 { return Memcached_DataObject::staticGet('Queue_item',$k,$v); }
22 /* the code above is auto generated do not remove the tag below */
26 * @param mixed $transports name of a single queue or array of queues to pull from
27 * If not specified, checks all queues in the system.
29 static function top($transports=null) {
31 $qi = new Queue_item();
33 if (is_array($transports)) {
34 // @fixme use safer escaping
35 $list = implode("','", array_map('addslashes', $transports));
36 $qi->whereAdd("transport in ('$list')");
38 $qi->transport = $transports;
41 $qi->orderBy('created');
42 $qi->whereAdd('claimed is null');
46 $cnt = $qi->find(true);
49 # XXX: potential race condition
50 # can we force it to only update if claimed is still null
52 common_log(LOG_INFO, 'claiming queue item id = ' . $qi->id .
53 ' for transport ' . $qi->transport);
55 $qi->claimed = common_sql_now();
56 $result = $qi->update($orig);
58 common_log(LOG_INFO, 'claim succeeded.');
61 common_log(LOG_INFO, 'claim failed.');