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 $notice_id; // int(4) primary_key not_null
14 public $transport; // varchar(8) primary_key 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 */
25 function sequenceKey()
26 { return array(false, false); }
28 static function top($transport) {
30 $qi = new Queue_item();
31 $qi->transport = $transport;
32 $qi->orderBy('created');
33 $qi->whereAdd('claimed is null');
37 $cnt = $qi->find(true);
40 # XXX: potential race condition
41 # can we force it to only update if claimed is still null
43 common_log(LOG_INFO, 'claiming queue item = ' . $qi->notice_id . ' for transport ' . $transport);
45 $qi->claimed = common_sql_now();
46 $result = $qi->update($orig);
48 common_log(LOG_INFO, 'claim succeeded.');
51 common_log(LOG_INFO, 'claim failed.');
58 function &pkeyGet($kv)
60 return Memcached_DataObject::pkeyGet('Queue_item', $kv);