36 $this->workerId = md5(microtime() . getmypid());
43 $prefix = $this->db->prefix;
45 $query =
"INSERT INTO {$prefix}queue 46 (name, data, timestamp) 48 (:name, :data, :timestamp)";
51 ':data' => serialize(
$item),
52 ':timestamp' => time(),
61 $prefix = $this->db->prefix;
65 $update =
"UPDATE {$prefix}queue 67 WHERE name = :name AND worker IS NULL 68 ORDER BY id ASC LIMIT 1";
70 ':worker' => $worker_id,
73 $num = $this->db->updateData($update,
true, $update_params);
78 $select =
"SELECT data 80 WHERE worker = :worker 83 ':worker' => $worker_id,
86 $obj = $this->db->getDataRow($select, null, $select_params);
91 $delete =
"DELETE FROM {$prefix}queue 93 AND worker = :worker";
95 ':worker' => $worker_id,
98 $this->db->deleteData(
$delete, $delete_params);
100 return unserialize($obj->data);
107 $prefix = $this->db->prefix;
109 $sql =
"DELETE FROM {$prefix}queue 115 $this->db->deleteData($sql,
$params);
122 $prefix = $this->db->prefix;
124 $sql =
"SELECT COUNT(id) AS total __construct($name,\Elgg\Database $db)
Create a queue.
$params
Saves global plugin settings.
clear()
{Clear all items from the queue.void}
dequeue()
{Remove an item from the queue.mixed}
FIFO queue that uses the database for persistence.
size()
{Get the size of the queue.int}
enqueue($item)
{Add an item to the queue.Item to add to queue bool}