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


PHP Client::getOptions方法代码示例

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


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

示例1: getTextsByUser

 /**
  * @param $hostUid
  * @param $key
  * @return null|UserText
  */
 public function getTextsByUser($hostUid, $cached = true)
 {
     if ($cached) {
         $pattern = $this->buildKey($hostUid, '*', '*');
         $prefix = $this->redis->getOptions()->prefix;
         $redisKeys = array_map(function ($redisKey) use($prefix) {
             if (substr($redisKey, 0, strlen($prefix)) == $prefix) {
                 $redisKey = substr($redisKey, strlen($prefix));
             }
             return $redisKey;
         }, $this->redis->keys($pattern));
         if (count($redisKeys) > 0) {
             $result = array_combine($redisKeys, $this->redis->mget($redisKeys));
             foreach ($result as $redisKey => $text) {
                 list(, , $userId, , $key, $lang) = explode(':', $redisKey);
                 $this->texts[$userId][$key][$lang] = $text;
             }
         }
     }
     if (!$cached || !isset($this->texts[$hostUid]) || !$this->texts[$hostUid]) {
         $this->texts[$hostUid] = $this->getTextsByHostFromMysql($hostUid);
         $mset = [];
         foreach ($this->texts[$hostUid] as $key => $langs) {
             foreach ($langs as $lang => $text) {
                 $mset[$this->buildKey($hostUid, $key, $lang)] = $text;
             }
         }
         if ($mset) {
             $this->redis->mset($mset);
         }
     }
     return $this->texts[$hostUid];
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:38,代码来源:DataProvider.php

示例2: getKeys

 /**
  * @param $queueName
  */
 private function getKeys($queueName, $useCache = false)
 {
     if (empty($this->keys) || !$useCache) {
         $this->keys = $this->redis->keys($this->getKeyPrefix($queueName) . '*');
     }
     $prefix = (string) $this->redis->getOptions()->prefix;
     $this->keys = array_map(function ($key) use($prefix) {
         return preg_replace('/^' . $prefix . '/', '', $key);
     }, $this->keys);
     return $this->keys;
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:14,代码来源:RedisQueue.php

示例3: purge

 /**
  * {@inheritdoc}
  */
 protected function purge()
 {
     try {
         $this->client->transaction(function ($tx) {
             $keyPrefix = $this->client->getOptions()->prefix;
             foreach (new \Predis\Collection\Iterator\Keyspace($this->client, '*') as $key) {
                 $tx->del(substr($key, strlen($keyPrefix)));
             }
         });
     } catch (\Predis\Transaction\AbortedMultiExecException $e) {
         return false;
     }
     return true;
 }
开发者ID:autocom,项目名称:smarty-redis,代码行数:17,代码来源:CacheResource.php

示例4: getParametersAndOptions

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

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

示例5: findSidsInRedis

 /**
  * @return array
  */
 public function findSidsInRedis()
 {
     $prefix = (string) $this->redis->getOptions()->prefix;
     $pattern = $this->getKey('');
     $prefixWithPattern = $prefix . $pattern;
     $keys = $this->redis->keys($pattern . '*');
     $sids = array_map(function ($key) use($prefixWithPattern) {
         return str_replace($prefixWithPattern, '', $key);
     }, $keys);
     return $sids;
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:14,代码来源:DataProvider.php

示例6: testConstructorWithNullAndNullArguments

 /**
  * @group disconnected
  */
 public function testConstructorWithNullAndNullArguments()
 {
     $client = new Client(null, null);
     $connection = $client->getConnection();
     $this->assertInstanceOf('Predis\\Connection\\SingleConnectionInterface', $connection);
     $parameters = $connection->getParameters();
     $this->assertSame($parameters->host, '127.0.0.1');
     $this->assertSame($parameters->port, 6379);
     $options = $client->getOptions();
     $this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion());
     $this->assertFalse($client->isConnected());
 }
开发者ID:rubensayshi,项目名称:predis,代码行数:15,代码来源:ClientTest.php

示例7: getKeys

 public function getKeys($pattern = '*')
 {
     $prefix = null;
     if ($this->client->getOptions()->__isset("prefix")) {
         $prefix = $this->client->getOptions()->__get("prefix")->getPrefix();
     }
     $keys = $this->client->keys($pattern);
     if ($prefix) {
         if (is_array($keys)) {
             for ($i = 0; $i < count($keys); $i++) {
                 $keys[$i] = str_replace($prefix, '', $keys[$i]);
             }
         } else {
             $keys = str_replace($prefix, '', $keys);
         }
     }
     return $keys;
 }
开发者ID:splitio,项目名称:php-client,代码行数:18,代码来源:PRedis.php

示例8: testCreateClientWithConnectionFromAggregatedConnection

 /**
  * @group disconnected
  */
 public function testCreateClientWithConnectionFromAggregatedConnection()
 {
     $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'), array('prefix' => 'pfx:'));
     $this->assertInstanceOf('Predis\\Connection\\ClusterConnectionInterface', $cluster = $client->getConnection());
     $this->assertInstanceOf('Predis\\Connection\\SingleConnectionInterface', $node01 = $client->getConnectionById('node01'));
     $this->assertInstanceOf('Predis\\Connection\\SingleConnectionInterface', $node02 = $client->getConnectionById('node02'));
     $clientNode02 = $client->getClientFor('node02');
     $this->assertInstanceOf('Predis\\Client', $clientNode02);
     $this->assertSame($node02, $clientNode02->getConnection());
     $this->assertSame($client->getOptions(), $clientNode02->getOptions());
 }
开发者ID:rodrigopbel,项目名称:ong,代码行数:14,代码来源:ClientTest.php


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