예제 #1
0
 public function getSocket($type = 'read')
 {
     $type = in_array($type, array('read', 'write')) ? $type : 'read';
     if (is_null($this->_hs[$type])) {
         $config = $this->_config;
         if (!is_array($config)) {
             throw new Pix_Exception('config error');
         }
         $hs = new HandlerSocket($config[$type]['host'], $config[$type]['port']);
         if ('write' == $type) {
             if (!$hs->openIndex(1, $config[$type]['dbname'], $config[$type]['table'], '', 'value')) {
                 throw new Exception($hs->getError());
             }
         } else {
             if (!$hs->openIndex(1, $config[$type]['dbname'], $config[$type]['table'], HandlerSocket::PRIMARY, 'key,value')) {
                 throw new Exception($hs->getError());
             }
         }
         $this->_hs[$type] = $hs;
     }
     return $this->_hs[$type];
 }
예제 #2
0
파일: Pecl.php 프로젝트: rusnak/Ext
 /**
  * Внутренний метод авторизации.
  *
  * @param HandlerSocket $driver Драйвер для которого следует выполнить авторизацию.
  * @param string $authKey Ключ авторизации.
  * @param int $authType Тип авторизации.
  * @return bool Результат выполнения операции.
  */
 protected function _auth($driver, $authKey, $authType)
 {
     return (bool) $driver->auth($authKey, $authType);
 }