當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::multiExec方法代碼示例

本文整理匯總了PHP中Predis\Client::multiExec方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::multiExec方法的具體用法?PHP Client::multiExec怎麽用?PHP Client::multiExec使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Predis\Client的用法示例。


在下文中一共展示了Client::multiExec方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: close

 /**
  * {@inheritdoc}
  */
 public function close()
 {
     $buffer =& $this->buffer;
     $this->redis->multiExec(function ($multi) use($buffer) {
         foreach ($buffer as $record) {
             $multi->rpush('monolog', $record);
         }
     });
 }
開發者ID:realestateconz,項目名稱:SncRedisBundle,代碼行數:12,代碼來源:RedisHandler.php

示例2: getMany

 /**
  * @param ModelInterface $model
  * @param array $ids
  * @return array
  */
 public function getMany(ModelInterface $model, array $ids = [])
 {
     $table = $this->getTableName($model);
     $this->db->multiExec();
     $data = [];
     if (empty($ids)) {
         $keys = $this->db->keys($table . ':*');
         foreach ($keys as $key) {
             $json = $this->db->get($key);
             $data[] = $model->fromRaw(json_decode($json));
         }
     } else {
         foreach ($ids as $id) {
             $data[] = $this->getById($model, $id);
         }
     }
     return $data;
 }
開發者ID:alexdevid,項目名稱:darinaerde,代碼行數:23,代碼來源:Storage.php

示例3: close

 /**
  * {@inheritdoc}
  */
 public function close()
 {
     if ($this->redis instanceof \Redis) {
         $multi = $this->redis->multi();
         foreach ($this->buffer as $record) {
             $multi->rpush($this->key, $record);
         }
         $multi->exec();
     } else {
         $key =& $this->key;
         $buffer =& $this->buffer;
         $this->redis->multiExec(function ($multi) use($key, $buffer) {
             foreach ($buffer as $record) {
                 $multi->rpush($key, $record);
             }
         });
     }
 }
開發者ID:ajoaugustine,項目名稱:tracker,代碼行數:21,代碼來源:RedisHandler.php

示例4: incrementAndCount

 /**
  * Calls the increment() and count() function using a single MULTI/EXEC block.
  *
  * @param string $subject  A unique identifier, for example a session id or an IP
  * @param int    $interval Interval in seconds
  *
  * @return int
  */
 public function incrementAndCount($subject, $interval)
 {
     $bucket = $this->getBucket();
     $subject = $this->key . ':' . $subject;
     $count = (int) floor($interval / $this->bucketInterval);
     $multi = $this->client->multiExec();
     $this->addMultiExecIncrement($multi, $subject, $bucket);
     $this->addMultiExecCount($multi, $subject, $bucket, $count);
     return array_sum(array_slice($multi->exec(), 4));
 }
開發者ID:jayesbe,項目名稱:SncRedisBundle,代碼行數:18,代碼來源:RateLimit.php

示例5: swapItems

 /**
  * {@inheritdoc}
  */
 public function swapItems($firstIndex, $secondIndex)
 {
     $this->initializeRedis();
     $key = $this->getKeyForItemList();
     $options = array('cas' => true, 'watch' => $key, 'retry' => 3);
     $this->redis->multiExec($options, function ($tx) use($key, $firstIndex, $secondIndex) {
         $firstItem = $tx->lindex($key, $firstIndex);
         $secondItem = $tx->lindex($key, $secondIndex);
         $tx->multi();
         $tx->lset($key, $firstIndex, $secondItem);
         $tx->lset($key, $secondIndex, $firstItem);
     });
 }
開發者ID:battlerattle,項目名稱:shuffle-bag,代碼行數:16,代碼來源:RedisStorage.php

示例6: removeTags

 /**
  * @param string $id
  * @param string[] $tags
  * @return bool
  */
 public function removeTags($id, array $tags)
 {
     if (count($tags) > 0) {
         $transaction = $this->redis->multiExec();
         $commandArgs = $tags;
         array_unshift($commandArgs, $this->getTagsForIdKey($id));
         $command = $this->redis->createCommand('srem', $commandArgs);
         $transaction->executeCommand($command);
         foreach ($tags as $tag) {
             $command = $this->redis->createCommand('srem', array($this->getIdsForTagKey($tag), $id));
             $transaction->executeCommand($command);
         }
         $responses = $transaction->exec();
         foreach ($responses as $response) {
             if ($response instanceof ResponseErrorInterface) {
                 return false;
             }
         }
     }
     return true;
 }
開發者ID:layeredcache,項目名稱:layeredcache,代碼行數:26,代碼來源:Predis.php

示例7: testMultiExecWithArrayAndCallableExecutesMultiExec

 /**
  * @group disconnected
  */
 public function testMultiExecWithArrayAndCallableExecutesMultiExec()
 {
     // NOTE: we use CAS since testing the actual MULTI/EXEC context
     //       here is not the point.
     $options = array('cas' => true, 'retry' => 3);
     $connection = $this->getMock('Predis\\Connection\\SingleConnectionInterface');
     $connection->expects($this->once())->method('executeCommand')->will($this->returnValue(new ResponseQueued()));
     $txCallback = function ($tx) {
         $tx->ping();
     };
     $callable = $this->getMock('stdClass', array('__invoke'));
     $callable->expects($this->once())->method('__invoke')->will($this->returnCallback($txCallback));
     $client = new Client($connection);
     $client->multiExec($options, $callable);
 }
開發者ID:rodrigopbel,項目名稱:ong,代碼行數:18,代碼來源:ClientTest.php


注:本文中的Predis\Client::multiExec方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。