简体   繁体   English

如何在 Nestjs 中设置 typeorm 连接池大小? (MySQL)

[英]How to Set typeorm connection pool size in Nestjs? (MySQL)

I saw this link create connection pool TypeOrm我看到这个链接创建连接池 TypeOrm

This article explained这篇文章解释了

"extra": {
  "connectionLimit": 5
}

But I thought that this is just max limit of connection instead of creating connection pool in advance但我认为这只是连接的最大限制,而不是提前创建连接池

How can I create typeorm(mysql) connection pool in Nestjs?如何在 Nestjs 中创建 typeorm(mysql) 连接池?

From the words of one of the authors:用其中一位作者的话来说:

TypeORM creates a connection pool and uses connection for a single operation (find, save, remove, etc.) - it takes the connection, uses it and releases it. TypeORM 创建一个连接池并将连接用于单个操作(查找、保存、删除等) - 它获取连接、使用它并释放它。 That's it.而已。 If all connections are busy it waits until any of them is released and then use it.如果所有连接都忙,它会等待它们中的任何一个被释放然后使用它。

If you want your pool to have a max size, then extra.connectionLimit is the way to go.如果您希望您的池具有最大大小,那么extra.connectionLimit是通往 go 的方式。

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

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