当前位置: 首页>>代码示例>>PHP>>正文


PHP Predis\Client类代码示例

本文整理汇总了PHP中Predis\Client的典型用法代码示例。如果您正苦于以下问题:PHP Client类的具体用法?PHP Client怎么用?PHP Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 public function save($client = null)
 {
     if ($client == null) {
         $client = new PredisClient();
     }
     $client->set($this->getId(), $this->toJson());
 }
开发者ID:eher,项目名称:ldd,代码行数:7,代码来源:Request.php

示例2: sort

 public function sort($tid, Request $request)
 {
     $sorts = BiliBiliHelper::getSorts();
     //分类非法检测
     if (!array_has($sorts, $tid)) {
         return $this->returnError('分类不存在');
     }
     $order = $request->get('order', 'hot');
     $page = $request->get('page', 1);
     //页码非法检测
     if ($page < 1) {
         $page = 1;
     }
     //默认取出redis
     if ($order == 'hot' && $page == 1) {
         $redis = new Client();
         $date = $redis->hget('update', 'sort');
         $sort = $redis->hget('sort', $sorts[$tid]);
         $sort = json_decode($sort, true);
     } else {
         try {
             $request_array = ['tid' => $tid, 'order' => $order, 'page' => $page, 'pagesize' => 20];
             $date = date('H:i:s');
             $back = RequestUtil::getUrl(BiliBiliHelper::$SERVICE_URL . '/sort?' . http_build_query($request_array));
             $sort = $back['content'];
         } catch (\Exception $e) {
             return $this->returnError('服务器君忙,待会再试吧...');
         }
     }
     return view('sort')->with('content', $sort)->with('tid', $tid)->with('page', $page)->with('date', $date);
 }
开发者ID:HouseStark,项目名称:BiliPusher,代码行数:31,代码来源:HomeController.php

示例3: getClient

 /**
  * Returns a new client instance.
  *
  * @return Client
  */
 protected function getClient()
 {
     $parameters = array('host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT, 'iterable_multibulk' => true, 'read_write_timeout' => 2);
     $client = new Client($parameters, REDIS_SERVER_VERSION);
     $client->connect();
     $client->select(REDIS_SERVER_DBNUM);
     $client->flushdb();
     return $client;
 }
开发者ID:keneanung,项目名称:gw2spidy,代码行数:14,代码来源:MultiBulkResponseTupleTest.php

示例4: testDispatcherLoopAgainstRedisServer

 /**
  * @group connected
  */
 public function testDispatcherLoopAgainstRedisServer()
 {
     $parameters = array('host' => REDIS_SERVER_HOST, 'port' => REDIS_SERVER_PORT, 'database' => REDIS_SERVER_DBNUM, 'read_write_timeout' => 2);
     $producer = new Client($parameters, REDIS_SERVER_VERSION);
     $producer->connect();
     $consumer = new Client($parameters, REDIS_SERVER_VERSION);
     $consumer->connect();
     $dispatcher = new DispatcherLoop($consumer);
     $function01 = $this->getMock('stdClass', array('__invoke'));
     $function01->expects($this->exactly(2))->method('__invoke')->with($this->logicalOr($this->equalTo('01:argument'), $this->equalTo('01:quit')))->will($this->returnCallback(function ($arg) use($dispatcher) {
         if ($arg === '01:quit') {
             $dispatcher->stop();
         }
     }));
     $function02 = $this->getMock('stdClass', array('__invoke'));
     $function02->expects($this->once())->method('__invoke')->with('02:argument');
     $function03 = $this->getMock('stdClass', array('__invoke'));
     $function03->expects($this->never())->method('__invoke');
     $dispatcher->attachCallback('function:01', $function01);
     $dispatcher->attachCallback('function:02', $function02);
     $dispatcher->attachCallback('function:03', $function03);
     $producer->publish('function:01', '01:argument');
     $producer->publish('function:02', '02:argument');
     $producer->publish('function:01', '01:quit');
     $dispatcher->run();
     $this->assertTrue($consumer->ping());
 }
开发者ID:keneanung,项目名称:gw2spidy,代码行数:30,代码来源:DispatcherLoopTest.php

示例5: getRedisClient

 /**
  * Lazy connection
  *
  * Get the connection to Redis server and return it
  *
  * @throws \Predis\Connection\ConnectionException
  */
 public function getRedisClient()
 {
     if (empty($this->redisHandler)) {
         $this->redisHandler = new RedisHandler();
     }
     return $this->redisHandler->getConnection();
 }
开发者ID:bcrazvan,项目名称:MateCat,代码行数:14,代码来源:AMQHandler.php

示例6: getParametersAndOptions

    protected function getParametersAndOptions(Client $client)
    {
        $parameters = $client->getConnection()->getParameters();
        $options = $client->getOptions();

        return array($parameters, $options);
    }
开发者ID:nrk,项目名称:PredisServiceProvider,代码行数:7,代码来源:ProviderTestCase.php

示例7: save

 /**
  * {@inheritdoc}
  */
 public function save()
 {
     $contents = $this->getForStorage();
     $this->client->set($this->key, $contents);
     if ($this->expire !== null) {
         $this->client->expire($this->key, $this->expire);
     }
 }
开发者ID:luoshulin,项目名称:falcon,代码行数:11,代码来源:Predis.php

示例8: copy

 /**
  * function that takes all keys from source redis, dumps them and imports to the new redis
  */
 public function copy()
 {
     // retrieve all keys from source redis
     $keys = $this->source->keys('*');
     $this->out("Processing %d REDIS keys ...", count($keys), true);
     $hundred = 0;
     $step = 0;
     foreach ($keys as $key) {
         // check for ignored keys and skip the key if it should be ignored
         foreach ($this->ignoredPrefixes as $ignoredPrefix) {
             if (strpos($key, $ignoredPrefix) !== false) {
                 $this->out('.');
                 continue 2;
                 // continue with the next key
             }
         }
         try {
             $ttl = max(0, (int) $this->source->ttl($key));
             $serializedValue = $this->source->dump($key);
             $this->destination->restore($key, $ttl, $serializedValue);
         } catch (Exception $e) {
             $this->out(PHP_EOL . 'ERROR: ' . $key . PHP_EOL);
         }
         if ($step++ % 100 == 0) {
             $this->out(PHP_EOL . $hundred++ . ': ');
         }
         $this->out('o');
     }
     $this->out(PHP_EOL . PHP_EOL);
 }
开发者ID:becquerel,项目名称:redis-copy,代码行数:33,代码来源:RedisCopy.php

示例9: testHandleLogWithGoodMessageNotImplementingJobInterface

 public function testHandleLogWithGoodMessageNotImplementingJobInterface()
 {
     $worker = new WorkerPresence();
     $worker->setMemory(12345);
     $frame = new Frame('MESSAGE', array('delivery_tag' => 'delivery-' . mt_rand()), $worker->toJson());
     $loop = LoopFactory::create();
     $options = array('eventloop' => $loop, 'on_error' => array($this, 'throwRedisError'));
     $redisSync = new PredisSync('tcp://127.0.0.1:6379');
     $redisSync->connect();
     $resolver = $this->getResolver();
     $resolver->expects($this->once())->method('ack');
     $done = false;
     $phpunit = $this;
     $redis = new PredisAsync('tcp://127.0.0.1:6379', $options);
     $redis->connect(function () use($resolver, $phpunit, $redis, $frame, $redisSync, &$done, $worker) {
         $component = new LogBuilderComponent();
         $component->handleLog($redis, $phpunit->getLogger(), $frame, $resolver)->then(function ($hashId) use($phpunit, $redis, $redisSync, &$done, $worker) {
             $redis->disconnect();
             $phpunit->assertEquals($worker->toJson(), $redisSync->get($hashId));
             $phpunit->assertTrue($redisSync->sismember('garbages', $hashId));
             $done = true;
         });
     });
     $loop->run();
     $this->assertTrue($done);
 }
开发者ID:gloubster,项目名称:server,代码行数:26,代码来源:LogBuilderComponentTest.php

示例10: expireIn

 public function expireIn($key, $seconds)
 {
     $redisTime = $this->client->time();
     $at = ceil($redisTime[0] + $seconds);
     $this->client->expireat($this->prefixTimestamp($key), $at);
     return (int) $this->client->expireat($this->prefixKey($key), $at) === 1;
 }
开发者ID:beheh,项目名称:flaps,代码行数:7,代码来源:PredisStorage.php

示例11: execute

 /**
  * @inheritdoc
  */
 public function execute(CommandInterface $command)
 {
     if (!$this->isConnected()) {
         throw new ConnectionException('No connection established');
     }
     return $this->client->executeRaw(array_merge([$command->getCommand()], $command->getArguments()));
 }
开发者ID:tonicospinelli,项目名称:disque-php,代码行数:10,代码来源:Predis.php

示例12: sendCountNotReadMessage

 /**
  * Отправляем метку количества не прочитанных сообщений
  *
  * @param int $user
  *
  * @return integer
  */
 protected function sendCountNotReadMessage($user)
 {
     $notReadMessage = $this->em->getRepository("UserMessagesBundle:Dialog")->findOneByNotReadMessage($user);
     if ($notReadMessage > 0) {
         $this->redis->publish('not-read', json_encode(['username' => 'username_' . $user, 'count' => $notReadMessage]));
     }
 }
开发者ID:rdbn,项目名称:shopsnmarkets,代码行数:14,代码来源:AbstractMessage.php

示例13: returnMessage

 public function returnMessage(QueueMessage $message)
 {
     // re-add the message to the queue, as the first element
     $this->predis->lpush($message->getQueueId(), $message->getMessage());
     // forget we received the message
     $this->completeMessage($message);
 }
开发者ID:silktide,项目名称:queueball-redis,代码行数:7,代码来源:Queue.php

示例14: createEvalShaKey

 /**
  * @return string
  */
 public function createEvalShaKey()
 {
     $code = file_get_contents($this->getPathToLuaDir() . self::SOURCE_CODE_FILENAME);
     $sha = $this->redis->script('LOAD', $code);
     file_put_contents($this->getPathToLuaDir() . self::EVAL_SHA_FILENAME, $sha);
     return $sha;
 }
开发者ID:avelov,项目名称:techery_friends,代码行数:10,代码来源:FriendsListScriptsHelper.php

示例15: publish

 /**
  * @param string $queue Name of the queue to receive the job
  * @param string $command FQCN for Command class to be executed by the job
  * @param array $options Options for the Command class instance
  */
 public function publish($queue, $command, array $options = [])
 {
     if (!is_subclass_of($command, CommandInterface::class)) {
         throw new \RuntimeException('Class does not implement CommandInterface: ' . $command);
     }
     $job = json_encode(['command' => $command, 'options' => $options]);
     $this->client->rpush($queue, $job);
 }
开发者ID:equip,项目名称:redis-queue,代码行数:13,代码来源:Publisher.php


注:本文中的Predis\Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。