Ejemplo n.º 1
0
 private static function getSphinxConnectionInternal($key, $connectTimeout)
 {
     if (!isset(self::$config['datasources'][$key]['connection']['dsn'])) {
         throw new Exception("DB Config [{$key}] not found");
     }
     $dataSource = self::$config['datasources'][$key]['connection']['dsn'];
     self::$sphinxConnection = new KalturaPDO($dataSource, null, null, array(PDO::ATTR_TIMEOUT => $connectTimeout, KalturaPDO::KALTURA_ATTR_NAME => $key), $key);
     self::$sphinxConnection->setCommentsEnabled(false);
     return self::$sphinxConnection;
 }
 private static function getConnection($key, $cacheExpiry, $connectTimeout)
 {
     try {
         if (!isset(self::$config['datasources'][$key]['connection']['dsn'])) {
             throw new Exception("DB Config [{$key}] not found");
         }
         $dataSource = self::$config['datasources'][$key]['connection']['dsn'];
         self::$sphinxConnection = new KalturaPDO($dataSource, null, null, array(PDO::ATTR_TIMEOUT => $connectTimeout, KalturaPDO::KALTURA_ATTR_NAME => $key));
         self::$sphinxConnection->setCommentsEnabled(false);
         KalturaLog::debug("getSphinxConnection: connected to {$key}");
         return self::$sphinxConnection;
     } catch (Exception $ex) {
         KalturaLog::debug("getSphinxConnection: failed to connect to {$key}");
         if (function_exists('apc_store')) {
             $cacheKey = "sphinxCon:" . $key;
             apc_store($cacheKey, 1, $cacheExpiry);
         }
     }
     return null;
 }