mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
Fix database connection pool contention (maybe)
Instead of acquiring a connection per service per request, we acquire connections more often but at a more granular level, meaning they're also disposed of more quickly instead of staying for a long time in case of long-running commands or leaks.
This commit is contained in:
parent
ca56fd419b
commit
d829630a35
8 changed files with 166 additions and 109 deletions
|
|
@ -333,4 +333,19 @@ namespace PluralKit
|
|||
return (T) value;
|
||||
}
|
||||
}
|
||||
|
||||
public class DbConnectionFactory
|
||||
{
|
||||
private string _connectionString;
|
||||
|
||||
public DbConnectionFactory(string connectionString)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
}
|
||||
|
||||
public IDbConnection Obtain()
|
||||
{
|
||||
return new NpgsqlConnection(_connectionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue