mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
由于FreeSql采用二次封装连接池,尽量避免使用问题,真实的max pool size值等于传入值+1
This commit is contained in:
parent
1c66796038
commit
decde799ae
@ -47,10 +47,14 @@ namespace FreeSql.MySql {
|
|||||||
public string ConnectionString {
|
public string ConnectionString {
|
||||||
get => _connectionString;
|
get => _connectionString;
|
||||||
set {
|
set {
|
||||||
_connectionString = value ?? "";
|
var connStr = value ?? "";
|
||||||
Match m = Regex.Match(_connectionString, @"Max\s*pool\s*size\s*=\s*(\d+)", RegexOptions.IgnoreCase);
|
var poolsizePatern = @"Max\s*pool\s*size\s*=\s*(\d+)";
|
||||||
|
Match m = Regex.Match(connStr, poolsizePatern, RegexOptions.IgnoreCase);
|
||||||
if (m.Success == false || int.TryParse(m.Groups[1].Value, out var poolsize) == false || poolsize <= 0) poolsize = 100;
|
if (m.Success == false || int.TryParse(m.Groups[1].Value, out var poolsize) == false || poolsize <= 0) poolsize = 100;
|
||||||
PoolSize = poolsize;
|
PoolSize = poolsize + 1;
|
||||||
|
_connectionString = m.Success ?
|
||||||
|
Regex.Replace(connStr, poolsizePatern, $"Max pool size={PoolSize}", RegexOptions.IgnoreCase) :
|
||||||
|
$"{connStr};Max pool size={PoolSize}";
|
||||||
|
|
||||||
var initConns = new Object<DbConnection>[poolsize];
|
var initConns = new Object<DbConnection>[poolsize];
|
||||||
for (var a = 0; a < poolsize; a++) try { initConns[a] = _pool.Get(); } catch { }
|
for (var a = 0; a < poolsize; a++) try { initConns[a] = _pool.Get(); } catch { }
|
||||||
|
@ -62,10 +62,14 @@ namespace FreeSql.Oracle {
|
|||||||
public string ConnectionString {
|
public string ConnectionString {
|
||||||
get => _connectionString;
|
get => _connectionString;
|
||||||
set {
|
set {
|
||||||
_connectionString = value ?? "";
|
var connStr = value ?? "";
|
||||||
Match m = Regex.Match(_connectionString, @"Max\s*pool\s*size\s*=\s*(\d+)", RegexOptions.IgnoreCase);
|
var poolsizePatern = @"Max\s*pool\s*size\s*=\s*(\d+)";
|
||||||
|
Match m = Regex.Match(connStr, poolsizePatern, RegexOptions.IgnoreCase);
|
||||||
if (m.Success == false || int.TryParse(m.Groups[1].Value, out var poolsize) == false || poolsize <= 0) poolsize = 100;
|
if (m.Success == false || int.TryParse(m.Groups[1].Value, out var poolsize) == false || poolsize <= 0) poolsize = 100;
|
||||||
PoolSize = poolsize;
|
PoolSize = poolsize + 1;
|
||||||
|
_connectionString = m.Success ?
|
||||||
|
Regex.Replace(connStr, poolsizePatern, $"Max pool size={PoolSize}", RegexOptions.IgnoreCase) :
|
||||||
|
$"{connStr};Max pool size={PoolSize}";
|
||||||
|
|
||||||
var initConns = new Object<DbConnection>[poolsize];
|
var initConns = new Object<DbConnection>[poolsize];
|
||||||
for (var a = 0; a < poolsize; a++) try { initConns[a] = _pool.Get(); } catch { }
|
for (var a = 0; a < poolsize; a++) try { initConns[a] = _pool.Get(); } catch { }
|
||||||
|
@ -57,10 +57,14 @@ namespace FreeSql.PostgreSQL {
|
|||||||
public string ConnectionString {
|
public string ConnectionString {
|
||||||
get => _connectionString;
|
get => _connectionString;
|
||||||
set {
|
set {
|
||||||
_connectionString = value ?? "";
|
var connStr = value ?? "";
|
||||||
Match m = Regex.Match(_connectionString, @"Maximum\s*pool\s*size\s*=\s*(\d+)", RegexOptions.IgnoreCase);
|
var poolsizePatern = @"Maximum\s*pool\s*size\s*=\s*(\d+)";
|
||||||
|
Match m = Regex.Match(connStr, poolsizePatern, RegexOptions.IgnoreCase);
|
||||||
if (m.Success == false || int.TryParse(m.Groups[1].Value, out var poolsize) == false || poolsize <= 0) poolsize = 100;
|
if (m.Success == false || int.TryParse(m.Groups[1].Value, out var poolsize) == false || poolsize <= 0) poolsize = 100;
|
||||||
PoolSize = poolsize;
|
PoolSize = poolsize + 1;
|
||||||
|
_connectionString = m.Success ?
|
||||||
|
Regex.Replace(connStr, poolsizePatern, $"Maximum pool size={PoolSize}", RegexOptions.IgnoreCase) :
|
||||||
|
$"{connStr};Maximum pool size={PoolSize}";
|
||||||
|
|
||||||
var initConns = new Object<DbConnection>[poolsize];
|
var initConns = new Object<DbConnection>[poolsize];
|
||||||
for (var a = 0; a < poolsize; a++) try { initConns[a] = _pool.Get(); } catch { }
|
for (var a = 0; a < poolsize; a++) try { initConns[a] = _pool.Get(); } catch { }
|
||||||
|
@ -51,10 +51,14 @@ namespace FreeSql.SqlServer {
|
|||||||
public string ConnectionString {
|
public string ConnectionString {
|
||||||
get => _connectionString;
|
get => _connectionString;
|
||||||
set {
|
set {
|
||||||
_connectionString = value ?? "";
|
var connStr = value ?? "";
|
||||||
Match m = Regex.Match(_connectionString, @"Max\s*pool\s*size\s*=\s*(\d+)", RegexOptions.IgnoreCase);
|
var poolsizePatern = @"Max\s*pool\s*size\s*=\s*(\d+)";
|
||||||
|
Match m = Regex.Match(connStr, poolsizePatern, RegexOptions.IgnoreCase);
|
||||||
if (m.Success == false || int.TryParse(m.Groups[1].Value, out var poolsize) == false || poolsize <= 0) poolsize = 100;
|
if (m.Success == false || int.TryParse(m.Groups[1].Value, out var poolsize) == false || poolsize <= 0) poolsize = 100;
|
||||||
PoolSize = poolsize;
|
PoolSize = poolsize + 1;
|
||||||
|
_connectionString = m.Success ?
|
||||||
|
Regex.Replace(connStr, poolsizePatern, $"Max pool size={PoolSize}", RegexOptions.IgnoreCase) :
|
||||||
|
$"{connStr};Max pool size={PoolSize}";
|
||||||
|
|
||||||
var initConns = new Object<DbConnection>[poolsize];
|
var initConns = new Object<DbConnection>[poolsize];
|
||||||
for (var a = 0; a < poolsize; a++) try { initConns[a] = _pool.Get(); } catch { }
|
for (var a = 0; a < poolsize; a++) try { initConns[a] = _pool.Get(); } catch { }
|
||||||
|
@ -53,10 +53,14 @@ namespace FreeSql.Sqlite {
|
|||||||
public string ConnectionString {
|
public string ConnectionString {
|
||||||
get => _connectionString;
|
get => _connectionString;
|
||||||
set {
|
set {
|
||||||
_connectionString = value ?? "";
|
var connStr = value ?? "";
|
||||||
var m = Regex.Match(_connectionString, @"Max\s*pool\s*size\s*=\s*(\d+)", RegexOptions.IgnoreCase);
|
var poolsizePatern = @"Max\s*pool\s*size\s*=\s*(\d+)";
|
||||||
|
Match m = Regex.Match(connStr, poolsizePatern, RegexOptions.IgnoreCase);
|
||||||
if (m.Success == false || int.TryParse(m.Groups[1].Value, out var poolsize) == false || poolsize <= 0) poolsize = 100;
|
if (m.Success == false || int.TryParse(m.Groups[1].Value, out var poolsize) == false || poolsize <= 0) poolsize = 100;
|
||||||
PoolSize = poolsize;
|
PoolSize = poolsize + 1;
|
||||||
|
_connectionString = m.Success ?
|
||||||
|
Regex.Replace(connStr, poolsizePatern, $"Max pool size={PoolSize}", RegexOptions.IgnoreCase) :
|
||||||
|
$"{connStr};Max pool size={PoolSize}";
|
||||||
|
|
||||||
var att = Regex.Split(_connectionString, @"Attachs\s*=\s*", RegexOptions.IgnoreCase);
|
var att = Regex.Split(_connectionString, @"Attachs\s*=\s*", RegexOptions.IgnoreCase);
|
||||||
if (att.Length == 2) {
|
if (att.Length == 2) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user