You are here

public function MongoDBQueue::createItem in MongoDB 7

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

array|bool If the item was successfully created and added to the queue.

Throws

\MongoConnectionException

\MongoCursorException

\MongoCursorTimeoutException

\MongoException

Overrides DrupalQueueInterface::createItem

File

mongodb_queue/mongodb_queue.inc, line 46
Contains \MongoDBQueue.

Class

MongoDBQueue

Code

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