On Fri, Jul 6, 2012 at 2:29 PM, Leonardo Augusto <lalin...@gmail.com> wrote: > cara o lance do mysql persistente connections é no php.ini..... > > (php.ini) > mysql.allow_persistent = Off (voce deve estar com ON ali, bota off !! e > testa ) > > E PELO AMOR DO BSD, INSTALA O MEMCACHE E COLOCA LA NAS QUERYES E NO > SESSION DO PHP. > > CARA, SE O MALUCO QUE FUTRICA COM PHP AI, NAO FEZ ISSO, PEGA UM 12 E > ATIRA BEM NA TESTA DO INFELIZ, kkk > > mas pra nao dizer que so falo e nao ajudo, pro php usar o memcache > como session handler é so por la no php.ini > > ; Use memcache as a session handler > session.save_handler=memcache > ; Defines a comma separated of server urls to use for session storage > ;session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15" > session.save_path="tcp://localhost:11211?persistent=1&retry_interval=15" > > - pra usar o memcahce no php, tem que instalar o php memcache lib la > ou coisa do tipo... > mas um exemplo de query, gera o hash do sql ve se ja tem, se nao tem > get from mysql and put into memcache, else get from memcache, sacou ? > > conectando... > > public function connect() // (obvio que é apenas um metodo de uma > classe extensa) > { > $ok = false; > try > { > //if( $this->mode == "TCP" ) > > //$this->dbh = new mysqli( $this->dbhost, $this->user, > $this->pass, $this->dbname, null, 'mysql' ); > $this->dbh = new mysqli( $this->dbhost, $this->user, > $this->pass, $this->dbname ); > > if( mysqli_connect_errno() ) > { > throw new Exception( sprintf("FALHA: %s\n", mysqli_connect_error() ) > ); > } > > mysqli_set_charset($this->dbh, 'utf8'); > > //mysql_query("SET CHARACTER SET utf8", $this->dbh ); > //mysql_query("SET NAMES utf8"); > //mysql_query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'"); // > medida extrema, opcional > /* > # Aqui está o segredo > mysql_query("SET NAMES 'utf8'"); > mysql_query('SET character_set_connection=utf8'); > mysql_query('SET character_set_client=utf8'); > mysql_query('SET character_set_results=utf8'); > conx = mysql_connect(xxxxxxx); > // dica para shared hosting > mysql_query("SET CHARACTER SET utf8"); > //mysql_query("SET NAMES utf8"); > //mysql_query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'"); // > medida extrema, opcional > */ > > //------------------------------------- > //--- Conecta ao memcached > //------------------------------------- > $this->memcacheOK = false; > if( class_exists("Memcache") ) > { > $this->memcache = new Memcache(); > if( $this->memcache->connect( SYS_CFG("MCHOST"), SYS_CFG("MCPORT") ) ) > { > $this->memcacheOK = true; > } > } > > $ok = true; > } > catch( Exception $e ) > { > $this->errorMsg = "Connect Error (File: ".$e->getFile().", Line > ".$e->getLine()."): ".$e->getMessage(); > echo $this->errorMsg; > } > return $ok; > } > > // a consulta propriamente dita > public function queryMC( $query, $timeout=600 ) // timeout==0 => no cache > { > $this->errorClear(); > $data = false; > > try > { > if( $this->memcacheOK && (int)$timeout > 0 ) // Se timeout==0 > nao usa o cache > { > $key = md5( $query ); > $data = $this->memcache->get( $key ); > > //echo "<!-- ###### PEGOU DO MEMCACHE::: "; > //if( $data == false ) echo " DATA RETURN FALSE-------"; > //echo $query."-->\n"; > } > > if( $data == false ) > { > //echo "<!-- @@@@ NAO PEGOU DO MEMCACHE::: ".$query."-->\n"; > > $result = $this->dbh->query( $query, MYSQLI_STORE_RESULT ); > if( $result == false ) > { > throw new Exception( $this->dbh->error ); > } > else > { > $data = array(); > while( $row = $result->fetch_array( MYSQLI_BOTH ) ) > { > $data[] = $row; > } > } > > if( $this->memcacheOK && (int)$timeout > 0 ) // Se > timeout==0 nao usa o cache > { > $this->memcache->set( $key, $data, 0, $timeout ); > } > $result->close(); > unset( $result); > } > } > catch( Exception $e ) > { > $this->errorMsg .= > "DBQueryMC(".sysUtil::SYS_GS("last_sysaction")."): > ".$e->getMessage()." => ".$query." [".$e->getTraceAsString()."] )"; > $this->errorCode = $e->getCode(); > $this->saveLogError(); > $data = array(); > } > > return $data; > } > > > AH LEMBREI DE OUTRA COISA > > usar o php com fast_cgi separado do apache(retirando o mod_php de > dentro dele) é melhor. > > > MAS USA O MEMCACHE CARA, do contrario.... pula da ponte... eheheh > > boa sorte
AH LEMBREI TAMBEM: ---------------------------------------------- - estao usando xcache, apc, ou coisa do tipo para o php ? - e o memcache ? vai ou ta dificil ? se nao usar cache e o memcache, faz o que eu disse, pega a 12 e se mata, kkkk senao daqui a pouco tao falando que o mysql e o php nao presta..... nem comento dai ne.. problema de BIOS ------------------------- Histórico: http://www.fug.com.br/historico/html/freebsd/ Sair da lista: https://www.fug.com.br/mailman/listinfo/freebsd