MongoDB samus Driver (1), mongodbsamus driver
Https://github.com/samus/mongodb-csharp
The official driver is not easy, so I used this,
1 var connectionString = new mongoonstringbuilder () 2 {3 ConnectionTimeout = TimeSpan. fromSeconds (30), 4 ConnectionLifetime = TimeSpan. fromSeconds (10), 5 MinimumPoolSize = 1, 6 MaximumPoolSize = 10, 7 Pooled = true, // use the connection pool 8 };
When a connection pool is used, a connection will be established every time a database command is specified. The connection pool will be slow, set to the maximum, and the connection pool will be slow,
_ Mongo. Disconnect () // release resources, no matter whether it is used. I don't know whether it is the drive BUG or other problems.
The solution in the project is to use a singleton connection:
Static IMongo _ mongo = null; // single-instance connection