You are here

public function QueueMongodb::createItem in MongoDB 8

Add a queue item and store it directly to the queue.

Parameters

object $data: Arbitrary data to be associated with the new task in the queue

Return value

boolean If the item was successfully created and added to the queue.

Overrides QueueInterface::createItem

File

src/QueueMongodb.php, line 54
Contains \Drupal\mongodb\QueueMongodb

Class

QueueMongodb
MongoDB queue implementation.

Namespace

Drupal\mongodb

Code

public function createItem($data) {
  $item = array(
    'data' => serialize($data),
    'created' => time(),
    'expire' => 0,
  );
  return $this
    ->mongoCollection()
    ->insert($item);
}