如何在 Apache::DBI 中禁用 ping?

发布于 2024-10-08 02:54:32 字数 474 浏览 0 评论 0原文

我在 Apache::DBI 中禁用连接验证时遇到问题。
来自 perldoc

Apache::DBI->setPingTimeOut($data_source, $超时)

这配置了 ping 的使用 方法,验证连接。 将超时设置为 0 将始终 使用验证数据库连接 ping 方法(默认)。设置 超时< 0 将停用 验证数据库句柄。

我尝试使用与 connect() 中相同的 $data_source 调用 setPingTimeOut 但它不起作用。有人设法禁用 ping 吗?

I have a problem disabling validation of the connection in Apache::DBI.
From the perldoc:

Apache::DBI->setPingTimeOut($data_source,
$timeout)

This configures the usage of the ping
method, to validate a connection.
Setting the timeout to 0 will always
validate the database connection using
the ping method (default). Setting the
timeout < 0 will de-activate the
validation of the database handle.

I tried calling setPingTimeOut with the same $data_source as in connect() but it didn't work. Did anyone manage to disable the pings?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你怎么这么可爱啊 2024-10-15 02:54:32

代码有:

# use a DSN without attribute settings specified within !
sub setPingTimeOut {
    my $class       = shift;
    my $data_source = shift;
    my $timeout     = shift;

    # sanity check
    if ($data_source =~ /dbi:\w+:.*/ and $timeout =~ /\-*\d+/) {
        $PingTimeOut{$data_source} = $timeout;
    }
}

为了澄清 “健全性检查”。因此,带有大写“DBI:”的数据源名称的 ping 超时将被静默忽略。

To clarify, the code has:

# use a DSN without attribute settings specified within !
sub setPingTimeOut {
    my $class       = shift;
    my $data_source = shift;
    my $timeout     = shift;

    # sanity check
    if ($data_source =~ /dbi:\w+:.*/ and $timeout =~ /\-*\d+/) {
        $PingTimeOut{$data_source} = $timeout;
    }
}

Note the 'sanity check'. Hence ping timeout for a data source name with uppercase 'DBI:' will be silently ignored.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文