Additional mysql settings

This commit is contained in:
Alexander Pankratov 2020-05-04 23:09:39 +03:00
parent ae9edd5512
commit ab168ce655
3 changed files with 14 additions and 4 deletions

View File

@ -4,6 +4,7 @@ namespace danog\MadelineProto\Db;
use Amp\Mysql\ConnectionConfig;
use Amp\Mysql\Pool;
use Amp\Sql\Common\ConnectionPool;
use function Amp\call;
use function Amp\Mysql\Pool;
use function Amp\Promise\wait;
@ -20,6 +21,9 @@ class Mysql
* @param string $password
* @param string $db
*
* @param int $maxConnections
* @param int $idleTimeout
*
* @return Pool
* @throws \Amp\Sql\ConnectionException
* @throws \Amp\Sql\FailureException
@ -30,7 +34,9 @@ class Mysql
int $port = 3306,
string $user = 'root',
string $password = '',
string $db = 'MadelineProto'
string $db = 'MadelineProto',
int $maxConnections = ConnectionPool::DEFAULT_MAX_CONNECTIONS,
int $idleTimeout = ConnectionPool::DEFAULT_IDLE_TIMEOUT
): Pool
{
$dbKey = "$host:$port:$db";
@ -40,7 +46,7 @@ class Mysql
);
static::createDb($config);
static::$connections[$dbKey] = pool($config);
static::$connections[$dbKey] = pool($config, $maxConnections, $idleTimeout);
}
return static::$connections[$dbKey];

View File

@ -247,6 +247,8 @@ class MysqlArray implements DbArray
$settings['user'],
$settings['password'],
$settings['database'],
$settings['max_connections'],
$settings['idle_timeout']
);
}

View File

@ -1320,8 +1320,10 @@ class MTProto extends AsyncConstruct implements TLCallback
'port' => 3306,
'user' => 'root',
'password' => '',
'database' => 'MadelineProto',
'cache_ttl' => '+1 day',
'database' => 'MadelineProto', //will be created automatically
'max_connections' => 10,
'idle_timeout' => 60,
'cache_ttl' => '+1 day', //keep records in memory after last read
]
],
'upload' => ['allow_automatic_upload' => true, 'part_size' => 512 * 1024, 'parallel_chunks' => 20], 'download' => ['report_broken_media' => true, 'part_size' => 1024 * 1024, 'parallel_chunks' => 20], 'pwr' => [