Exemplo n.º 1
0
 /**
  * @param SplObjectStorage $listaNotificacoes
  * @return void
  */
 public function adicionarVarios(SplObjectStorage &$listaNotificacoes)
 {
     $batchNotificacoes = array();
     $batchNotificacoesPorUsuario = array();
     $dataEnvio = time();
     foreach ($listaNotificacoes as $notificacao) {
         $UUID = UUID::mint();
         $notificacao->setId($UUID->string);
         $notificacao->setDataEnvio($dataEnvio);
         $usuarioId = $notificacao->getDestinatario()->getId();
         $batchNotificacoes[$UUID->bytes] = $notificacao->toCassandra();
         $batchNotificacoesPorUsuario[$usuarioId] = array($UUID->bytes => '');
     }
     $this->_cf->batch_insert($batchNotificacoes);
     $this->_notificacoesPorUsuarioCF->batch_insert($batchNotificacoesPorUsuario);
     $this->_notificacoesNovasPorUsuarioCF->batch_insert($batchNotificacoesPorUsuario);
 }
 /**
  * @param string $usuarioId
  * @param array $listaDeRS
  * @return void
  */
 private function _salvarListaDeRS($usuarioId, array $listaDeRS)
 {
     if (empty($listaDeRS)) {
         return;
     }
     $batchListaRS = array();
     $listaRSKeys = array();
     foreach ($listaDeRS as $RS) {
         $rsUIID = UUID::mint();
         $RS->setId($rsUIID->string);
         $batchListaRS[$rsUIID->bytes] = $RS->toCassandra();
         $listaRSKeys[$rsUIID->bytes] = '';
         $RS->setPersistido(true);
     }
     $this->_RSCF->batch_insert($batchListaRS);
     $this->_RSPorUsuarioCF->insert($usuarioId, $listaRSKeys);
 }
Exemplo n.º 3
0
 /**
  * Inserts or updates columns in multiple rows. Note that this operation is only atomic
  * per row.
  *
  * @param array $rows an array of keys, each of which maps to an array of columns. This
  *        looks like array(key => array(column_name => column_value))
  * @param int $timestamp the timestamp to use for these insertions. Leaving this as null will
  *        result in a timestamp being generated for you
  * @param int $ttl time to live for the columns; after ttl seconds they will be deleted
  * @param cassandra_ConsistencyLevel $writeConsistencyLevel affects the guaranteed
  *        number of nodes that must respond before the operation returns
  *
  * @return int the timestamp for the operation | false
  */
 public function batchInsert($rows, $timestamp = null, $ttl = null, $writeConsistencyLevel = null)
 {
     return $timestamp === $this->_columnFamily->batch_insert($rows, $timestamp, $ttl, $writeConsistencyLevel);
 }