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


PHP Client::pipeline方法代碼示例

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


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

示例1: markUserOnline

 public function markUserOnline($pageKey, $userIdent)
 {
     $thisMinute = floor(time() / 60) * 60;
     $key = $this->makeUsersOnlineKey($pageKey, $thisMinute);
     $this->redis->pipeline(function (Pipeline $p) use($key, $userIdent) {
         $p->sadd($key, $userIdent);
         $p->expire($key, self::ONLINE_MINUTES * 60);
     });
 }
開發者ID:skrz,項目名稱:cc15-mongo-es-redis-rabbitmq,代碼行數:9,代碼來源:RedisService.php

示例2: multiPut

 /**
  * @param string $queueName
  * @param array  $workloads
  */
 public function multiPut($queueName, array $workloads)
 {
     $pipeline = $this->predis->pipeline();
     foreach ($workloads as $workload) {
         /** @noinspection PhpUndefinedMethodInspection */
         $pipeline->lpush($queueName, serialize($workload));
     }
     $pipeline->execute();
 }
開發者ID:riverline,項目名稱:worker-bundle,代碼行數:13,代碼來源:PRedis.php

示例3: set

 public function set($keyValue)
 {
     $pipe = $this->redis->pipeline();
     foreach ($keyValue as $key => $value) {
         if (!is_null($value)) {
             $value = json_encode($value);
             $pipe->setex($key, 86400, $value);
             // 緩存 1 天
         }
     }
     return $pipe->execute();
 }
開發者ID:angejia,項目名稱:pea,代碼行數:12,代碼來源:RedisCache.php

示例4: updateValues

 /**
  *
  */
 private function updateValues()
 {
     $this->registeredStates = $this->redis->smembers(self::STATE_MACHINE_NAMESPACE . 'registry');
     if (count($this->registeredStates) > 0) {
         $currentValueRedisKeys = array_map([$this, 'buildCurrentKey'], $this->registeredStates);
         $previousValueRedisKeys = array_map([$this, 'buildPreviousKey'], $this->registeredStates);
         list($currentValues, $previousValues) = $this->redis->pipeline(function (Pipeline $pipe) use($currentValueRedisKeys, $previousValueRedisKeys) {
             $pipe->mget($currentValueRedisKeys);
             $pipe->mget($previousValueRedisKeys);
         });
         $this->currentValues = array_combine($this->registeredStates, $currentValues);
         $this->previousValues = array_combine($this->registeredStates, $previousValues);
     }
 }
開發者ID:akentner,項目名稱:incoming-ftp,代碼行數:17,代碼來源:StateMachine.php

示例5: setMany

 /**
  * Inserts many items in the cache.
  *
  * @param array $values
  * @param int $minutes
  *
  * @return mixed
  */
 public function setMany(array $values, int $minutes)
 {
     $this->predis->pipeline(function ($pipe) use($values, $minutes) {
         foreach ($values as $key => $value) {
             $value = is_numeric($value) ? $value : serialize($value);
             $pipe->setex($this->prefix . $key, 60 * $minutes, $value);
         }
     });
 }
開發者ID:domynation,項目名稱:domynation-framework,代碼行數:17,代碼來源:RedisCache.php

示例6: remClear

 /**
  * Clear the entire cache.
  */
 public static function remClear()
 {
     $keys = self::remAllKeys();
     self::$_redis->pipeline(function ($pipe) use($keys) {
         foreach ($keys as $key) {
             Rem::remDeleteKey($key, $pipe);
         }
     });
 }
開發者ID:chriskite,項目名稱:rem,代碼行數:12,代碼來源:Rem.php

示例7: storePosts

 /**
  * Batch store
  */
 public function storePosts()
 {
     if (!$this->isValid()) {
         return false;
     }
     try {
         // would break this up i.e. only pipeline 5000 at a time
         $this->storage->pipeline(function ($pipe) {
             foreach ($this->rawpost->getData() as $data) {
                 $postback = [];
                 $postback['method'] = $this->rawpost->getMethod();
                 $postback['url'] = $this->rawpost->getUrl();
                 $postback['data'] = $data;
                 $pipe->lpush('job-queue', json_encode($postback));
             }
         });
     } catch (\Exception $e) {
         $this->error = $e->getMessage();
         return false;
     }
     return true;
 }
開發者ID:jessecascio,項目名稱:postback-example,代碼行數:25,代碼來源:PostStore.php

示例8: testPipelineWithArrayAndCallableExecutesPipelineWithOptions

 /**
  * @group disconnected
  */
 public function testPipelineWithArrayAndCallableExecutesPipelineWithOptions()
 {
     $executor = $this->getMock('Predis\\Pipeline\\PipelineExecutorInterface');
     $options = array('executor' => $executor);
     $test = $this;
     $mockCallback = function ($pipeline) use($executor, $test) {
         $reflection = new \ReflectionProperty($pipeline, 'executor');
         $reflection->setAccessible(true);
         $test->assertSame($executor, $reflection->getValue($pipeline));
     };
     $callable = $this->getMock('stdClass', array('__invoke'));
     $callable->expects($this->once())->method('__invoke')->with($this->isInstanceOf('Predis\\Pipeline\\PipelineContext'))->will($this->returnCallback($mockCallback));
     $client = new Client();
     $client->pipeline($options, $callable);
 }
開發者ID:rodrigopbel,項目名稱:ong,代碼行數:18,代碼來源:ClientTest.php

示例9: createPipeline

 public function createPipeline()
 {
     return $this->redis->pipeline();
 }
開發者ID:maximebf,項目名稱:cachecache,代碼行數:4,代碼來源:Redis.php

示例10: testPipelineWithCallableExecutesPipeline

 /**
  * @group disconnected
  */
 public function testPipelineWithCallableExecutesPipeline()
 {
     $callable = $this->getMock('stdClass', array('__invoke'));
     $callable->expects($this->once())->method('__invoke')->with($this->isInstanceOf('Predis\\Pipeline\\Pipeline'));
     $client = new Client();
     $client->pipeline($callable);
 }
開發者ID:pikniktech,項目名稱:dailybriefweb2,代碼行數:10,代碼來源:ClientTest.php


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