简体   繁体   English

持续连接

[英]persistent connection

I'm writing php web-app using unholy alliance of php+oracle+iis :) every time script being executed I create a new connection to db - and it takes time: 我正在使用php + oracle + iis的邪恶联盟编写php web-app :)每次执行脚本时,我都会与db建立新的连接-这需要时间:

class ORACLE_layer {

    public function __construct($usr, $pwd, $db) {
        $this->conn = oci_connect ("...")
    }

    function __destruct() {
       oci_close($this->conn);
    }
}

I heard of "persistent connections". 我听说“持久连接”。 Should I use them? 我应该使用它们吗? "oci_pconnect" Do I need to remove the line: "oci_close($this->conn);" “ oci_pconnect”是否需要删除以下行:“ oci_close($ this-> conn);” from "__destruct"? 从“ __destruct”?

Whether you should use them or not cannot be answered without some consideration: 没有考虑,就无法回答是否应该使用它们:

Using oci_pconnect() makes a big improvement in overall connection speed of frequently used applications because it uses the connection cache in PHP. 使用oci_pconnect()可以大大提高常用应用程序的整体连接速度,因为它使用了PHP中的连接缓存。 A new, physical connection to the database does not have to be created if one already exists in PHP's cache. 如果PHP的缓存中已经存在一个新的物理连接,则不必创建该数据库。 However if currently unused, open persistent connections consume too much memory on the database server, consider tuning the timeout parameters or using connection pooling. 但是,如果当前未使用的打开的持久连接消耗了数据库服务器上的太多内存,请考虑调整超时参数或使用连接池。

Check out 查看

to learn more about connecting to Oracle from PHP efficiently. 了解有关从PHP有效连接到Oracle的更多信息。

Check out datable resident connection pools available as of 11.2. 检出从11.2开始可用的datable驻留连接池。 This will resolve your issue. 这样可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM