public function setDueDate($key, $value, $timestamp, array $tags = null)
{
$document = array('_id' => $key, self::FIELD_NAME_VALUE => $value);
if ($timestamp) {
$document[self::FIELD_NAME_EXPIRED] = new \MongoDate((int) $timestamp);
}
if ($tags) {
$document[self::FIELD_NAME_TAGS] = $tags;
}
$result = $this->collection->getMongoCollection()->update(array('_id' => $key), $document, array('upsert' => true));
if ((double) 1 !== $result['ok']) {
throw new Exception('Error setting value');
}
return $this;
}