php - 在 Doctrine2 上设置无限超时

标签 php mongodb symfony doctrine-orm

对于Symfony2.3 中使用的MongoDb,如何将超时设置为无限制?尝试在 30 秒超时后设置限制和查询,但“原始”查询在 Mongodb CLI 上工作正常,需要大约 90 秒(或更多)才能完成。

$qb = $this->createQueryBuilder('BaseLog')
->hydrate(true)
 ->field('template_id')->Equals($templateId);
...
return $qb->getQuery(array('timeout' => -1))->execute();

最佳答案

似乎是 MongoDB 游标对象的超时(可以按照 here 中的说明更改超时)。

使用 DoctrineMongoDBBundle,您可以修改 timeout 配置键,如 here 所述.修改config.yml为例,如下:

# app/config/config.yml
doctrine_mongodb:
    connections:
        default:
            server: mongodb://localhost:27017
            options:
              timeout: 240  # <-- increase the default timeout

    default_database: hello_%kernel.environment%
    document_managers:
        default:
            mappings:
                AcmeDemoBundle: ~
            filters:
                filter-name:
                    class: Class\Example\Filter\ODM\ExampleFilter
                    enabled: true
            metadata_cache_driver: array # array, apc, xcache, memcache

希望对你有帮助

关于php - 在 Doctrine2 上设置无限超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34065964/

相关文章:

java - 无法使用带参数的构造函数 NO_CONSTRUCTOR 实例化 org.springframework.security.authentication.UsernamePasswordAuthenticationToken

mongodb - "This node was not started with the replSet option"

php - Symfony2 - 数据库级别 onDelete Cascade 不会触发生命周期事件

javascript - 使用相同的 ajax 调用填充 3 个元素

php - 修复此特定 SQL 注入(inject)漏洞的示例代码

javascript - Mongodb数据插入问题

php - Symfony 如何验证 EntityType 字段

javascript - Javascript 中的 Symfony2 密码编码器函数

php - postfix 在 Ubuntu 15.04 中不发送邮件

php - 在 FreeBSD 8.3 上安装 php5-gd 时出错(共享库 "png.6"不存在)