开发者

Can MySQL link (mysql_connect) be stored in Memcache and reused?

开发者 https://www.devze.com 2023-03-09 01:43 出处:网络
In PHP, can I do this? $mysql = mysql_connect(...); Memcache::set(\'mysql_connection\', $mysql); and then in another scrip开发者_高级运维t

In PHP, can I do this?

$mysql = mysql_connect(...);
Memcache::set('mysql_connection', $mysql);

and then in another scrip开发者_高级运维t

$mysql = Memcache::get('mysql_connection');
mysql_query("some query", $mysql);

?


No, but you can use a pool of permanent connections with mysql_pconnect().


No, it can't. $mysql is actually just a memory pointer to the real MySQL link. The MySQL link is destroyed at the end of the script whether you want it or not, and you are left with a pointer to an undefined place in memory.

0

精彩评论

暂无评论...
验证码 换一张
取 消