0

出于性能原因,我正在将 php 转换为从 cgi 模式运行到模块模式。

在 CGI 模式下,每次都在执行 php 代码。我感觉通过这种转换,php 代码将像 Java 一样在内存中运行。这意味着如果用户类在用户首次登录时被实例化,它将作为一个类保留在内存中。但似乎并非如此。每次都需要执行所有代码。

有没有办法像java一样运行PHP?

谢谢

4

2 回答 2

2

No, module version of PHP works the same as CGI version in that regard, so you cannot keep class "in memory" between requests.

So, you still need to store/serialize your data between requests, that means use sessions, because every request will be processed by a "new" script.

You want to use "Application Server", but PHP doesn't work that way (AFAIK), and PHP Apache module is not an application server.

于 2011-01-11T00:33:49.120 回答
0

我对您的问题并不完全清楚,但是如果您询问缓存 php 文件的字节码以减少加载时间,我会考虑使用 APC(http://php.net/manual/en/book.apc。 php)。

它将缓存 php 的字节码并显着减少加载未更改的类所需的时间。

于 2011-01-11T00:05:15.870 回答