public function Predis::createItem in Redis 8
Adds a queue item and store it directly to the queue.
Parameters
$data: Arbitrary data to be associated with the new task in the queue.
Return value
A unique ID if the item was successfully created and was (best effort) added to the queue, otherwise FALSE. We don't guarantee the item was committed to disk etc, but as far as we know, the item is now in the queue.
Overrides QueueInterface::createItem
File
- src/
Queue/ Predis.php, line 37
Class
- Predis
- Redis queue implementation using Predis library backend.
Namespace
Drupal\redis\QueueCode
public function createItem($data) {
// TODO: Fixme
$record = new \stdClass();
$record->data = $data;
$record->qid = $this
->incrementId();
// We cannot rely on REQUEST_TIME because many items might be created
// by a single request which takes longer than 1 second.
$record->timestamp = time();
if (!$this->client
->hsetnx($this->availableItems, $record->qid, serialize($record))) {
return FALSE;
}
$start_len = $this->client
->lLen($this->availableListKey);
if ($start_len < $this->client
->lpush($this->availableListKey, $record->qid)) {
return $record->qid;
}
}