Confusion arises as to when PHP starts a new connection using all the
"persistent" versions of any function, and this depends entirely on how you
run your PHP.
In real CGI mode, that is, one process per script, persistent functions do the
exact same as their "temporary" equivalents. If you have a threaded Apache
MPM, this persistence will open a connection per thread, but not immediately.
Think of it as a single PHP instance for each thread.
If you run prefork, the MPM that forks the Apache server into several
accept()ing subprocesses, you'll have one PHP instance per process.
This isn't always true as I might've missed some gotchas, but in general, do
know that a persistent can only try to be persistent.
As for grey at greywyvern dot moc: A cronjob would be a lot better suited
for this, and have it periodically update the index rather than request ~200
pages each time somebody searches, at least from what you describe it as.
本文探讨了PHP中使用持久连接的功能及其实现方式。在不同的运行环境下(如CGI模式、多线程Apache MPM等),持久连接的行为各异,并解释了其如何在不同场景下开启新的数据库连接。此外,还提出了对于大量页面更新任务,使用定时任务而非每次搜索时请求的方式更为高效。
287

被折叠的 条评论
为什么被折叠?



