当前位置: 首页>>代码示例>>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;未经允许,请勿转载。