當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。