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


PHP Redis::__construct方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     parent::__construct();
     $config = Config::$redis;
     $this->connect($config['host'], $config['port']);
     $this->auth($config['auth']);
 }
开发者ID:zuozuoba,项目名称:zpf,代码行数:7,代码来源:iredis.php

示例2: __construct

 public function __construct($params = array())
 {
     parent::__construct();
     $this->ci =& get_instance();
     $configFile = 'redis';
     $this->ci->config->load($configFile, true);
     $servers = $this->ci->config->item('servers', $configFile);
     $timeout = $this->ci->config->item('timeout', $configFile);
     $dbName = isset($params['db_name']) ? $params['db_name'] : 'web_db';
     $database = $this->ci->config->item($dbName, $configFile);
     $succ = false;
     $i = -1;
     $retry = 3;
     shuffle($servers);
     while (!$succ && $retry--) {
         $i = ($i + 1) % count($servers);
         $server = $servers[$i];
         try {
             $succ = $this->connect($server['host'], $server['port'], $timeout);
             $succ = $this->select($database);
         } catch (Exception $e) {
             if ($retry == 1) {
                 $logParams = array('host' => $server['host'], 'port' => $server['port'], 'timeout' => $timeout, 'message' => $e->getMessage());
                 $this->ci->log->log('error', 'connect to redis failed', $logParams);
                 throw $e;
             }
         }
     }
 }
开发者ID:zhanghw0354,项目名称:webframework,代码行数:29,代码来源:RedisClient.php

示例3: exit

 /**
  * 
  * redis 构造函数
  * 
  * @param array $config
  * 
  * @return \Redis
  */
 function __construct($config)
 {
     parent::__construct();
     $this->config = array_merge($this->config, $config);
     if (php_sapi_name() == 'cli') {
         if ($this->connect($config['host'], $config['port'], $config['timeout']) == false) {
             echo "Redis '{$config['host']}' Connected Failed. \n";
             exit($this->getLastError());
         }
     } else {
         if ($this->pconnect($config['host'], $config['port'], $config['timeout']) == false) {
             echo "Redis '{$config['host']}' Connected Failed. \n";
             exit($this->getLastError());
         }
     }
     if ($config['password']) {
         if ($this->auth($config['password']) == false) {
             echo "Redis '{$config['host']}' Password Is Incorrect. \n";
             exit($this->getLastError());
         }
     }
     //选择库
     $this->select($config['database']);
     //开启自动序列化
     if ($config['serialization']) {
         $this->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
     }
 }
开发者ID:beyondye,项目名称:ENPHP,代码行数:36,代码来源:redis.php

示例4: __construct

 public function __construct($host, $database = 0, $password = null, $timeout = 0)
 {
     parent::__construct();
     $server = explode(':', $host);
     $this->host = $server[0];
     $this->port = $server[1];
     $this->password = $password;
     $this->timeout = $timeout;
     $this->establishConnection();
 }
开发者ID:farmani,项目名称:yii2-resque,代码行数:10,代码来源:Redis.php

示例5: __construct

 /**
  * constructor method
  *
  * @param string $name        Name of the connection
  * @param string $environment The kernel environment variable
  * @param array  $parameters  Configuration parameters
  */
 public function __construct($name, $environment, array $parameters = [])
 {
     parent::__construct();
     if ($parameters['skip_env']) {
         $prefix = $name . ':';
     } else {
         $prefix = $name . '.' . $environment . ':';
     }
     if (empty($parameters['prefix'])) {
         $parameters['prefix'] = $prefix;
     } else {
         $parameters['prefix'] .= '.' . $prefix;
     }
     $this->name = $name;
     $this->parameters = $parameters;
 }
开发者ID:pompdelux,项目名称:phpredis-bundle,代码行数:23,代码来源:PHPRedis.php

示例6: __construct

 public function __construct($redisconfig = array())
 {
     parent::__construct();
     if (empty($redisconfig)) {
         $redisconfigs = load_config("redis");
         $redisconfig = $redisconfigs['default'];
     }
     if (!empty($redisconfig['host']) && empty($redisconfig['port']) && empty($redisconfig['timeout'])) {
         parent::connect($redisconfig['host']);
     } else {
         if (!empty($redisconfig['host']) && !empty($redisconfig['port']) && empty($redisconfig['timeout'])) {
             parent::connect($redisconfig['host'], $redisconfig['port']);
         } else {
             if (!empty($redisconfig['host']) && !empty($redisconfig['port']) && !empty($redisconfig['timeout'])) {
                 parent::connect($redisconfig['host'], $redisconfig['port'], $redisconfig['timeout']);
             }
         }
     }
     if (!empty($redisconfig['auth'])) {
         parent::auth($redisconfig['auth']);
     }
 }
开发者ID:sunqinye,项目名称:SunPHP,代码行数:22,代码来源:Rediz.php

示例7: __construct

 public function __construct($namespace = null, $config = [])
 {
     parent::__construct();
     $namespace = $namespace ?: __NAMESPACE__;
     $defaults = static::$_defaults;
     static::$_defaults = Hash::merge(self::$_defaults, static::$_defaults);
     $this->_config = $this->_config($namespace, $config);
     static::$_defaults = $defaults;
     // настраиваем тестовое окружение
     $connection = defined('TESTING_IS_GOING_ON') && TESTING_IS_GOING_ON && !empty($this->_config['test']) ? $this->_config['test'] : $this->_config['server'];
     // коннектимся
     $this->connect($connection['host'], $connection['port']);
     // если есть пароль то логинимся
     if (!empty($connection['password'])) {
         if (!$this->auth($connection['password'])) {
             throw new Exception('Wrong password');
         }
     }
     if (!empty($connection['database'])) {
         $this->select($connection['database']);
     }
 }
开发者ID:pdedkov,项目名称:db,代码行数:22,代码来源:Instance.php

示例8: __construct

 public function __construct()
 {
     parent::__construct();
 }
开发者ID:nbaiwan,项目名称:yav,代码行数:4,代码来源:CRedis.php

示例9: __construct

 public function __construct()
 {
     parent::__construct();
     $this->connect($this->host, $this->port);
     $this->auth($this->login);
 }
开发者ID:visionp,项目名称:TestFramework,代码行数:6,代码来源:Redis.php


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