35 $this->workerId = md5(microtime() . getmypid());
42 $prefix = $this->db->prefix;
43 $name = $this->db->sanitizeString($this->
name);
44 $blob = $this->db->sanitizeString(serialize(
$item));
47 $query =
"INSERT INTO {$prefix}queue 48 SET name = '$name', data = '$blob', timestamp = $time";
49 return $this->db->insertData($query) !==
false;
56 $prefix = $this->db->prefix;
57 $name = $this->db->sanitizeString($this->
name);
58 $worker_id = $this->db->sanitizeString($this->workerId);
60 $update =
"UPDATE {$prefix}queue 61 SET worker = '$worker_id' 62 WHERE name = '$name' AND worker IS NULL 63 ORDER BY id ASC LIMIT 1";
64 $num = $this->db->updateData($update,
true);
66 $select =
"SELECT data FROM {$prefix}queue 67 WHERE worker = '$worker_id'";
68 $obj = $this->db->getDataRow(
$select);
70 $data = unserialize($obj->data);
71 $delete =
"DELETE FROM {$prefix}queue 72 WHERE name = '$name' AND worker = '$worker_id'";
73 $this->db->deleteData($delete);
85 $prefix = $this->db->prefix;
86 $name = $this->db->sanitizeString($this->
name);
88 $this->db->deleteData(
"DELETE FROM {$prefix}queue WHERE name = '$name'");
95 $prefix = $this->db->prefix;
96 $name = $this->db->sanitizeString($this->
name);
98 $result = $this->db->getDataRow(
"SELECT COUNT(id) AS total FROM {$prefix}queue WHERE name = '$name'");
__construct($name,\Elgg\Database $db)
Create a queue.
clear()
{Clear all items from the queue.void}
dequeue()
{Remove an item from the queue.mixed}
size()
{Get the size of the queue.int}
enqueue($item)
{Add an item to the queue.Item to add to queue bool}