Browse Source

Increased number of database connections (#6707)

Co-authored-by: LLT21 <[email protected]>
LLT21 4 years ago
parent
commit
c446425188

+ 3 - 4
frameworks/CSharp/appmpower/src/Db/PooledConnection.cs

@@ -9,7 +9,7 @@ namespace appMpower.Db
    public class PooledConnection : IDbConnection
    {
       private bool _isInUse = true;
-      private byte _number = 0;
+      private short _number = 0;
       private OdbcConnection _odbcConnection;
       private ConcurrentDictionary<string, PooledCommand> _pooledCommands;
 
@@ -47,7 +47,7 @@ namespace appMpower.Db
          }
       }
 
-      public byte Number
+      public short Number
       {
          get
          {
@@ -182,11 +182,10 @@ namespace appMpower.Db
          else
          {
             pooledCommand.OdbcCommand = new OdbcCommand(commandText, this.OdbcConnection);
+            pooledCommand.OdbcCommand.Prepare();
             pooledCommand.PooledConnection = this;
-            _pooledCommands.TryAdd(commandText, pooledCommand);
 
             //Console.WriteLine("prepare pool connection: " + this._number + " for command " + _pooledCommands.Count);
-            pooledCommand.OdbcCommand.Prepare();
          }
 
          return pooledCommand;

+ 2 - 2
frameworks/CSharp/appmpower/src/Db/PooledConnections.cs

@@ -8,8 +8,8 @@ namespace appMpower.Db
    public static class PooledConnections
    {
       private static bool _connectionsCreated = false;
-      private static byte _createdConnections = 0;
-      private static byte _maxConnections = 255; //Math.Min((byte)Environment.ProcessorCount, (byte)21);
+      private static short _createdConnections = 0;
+      private static short _maxConnections = 512; //Math.Min((byte)Environment.ProcessorCount, (byte)21);
       private static ConcurrentStack<PooledConnection> _stack = new ConcurrentStack<PooledConnection>();
       private static ConcurrentQueue<TaskCompletionSource<PooledConnection>> _waitingQueue = new ConcurrentQueue<TaskCompletionSource<PooledConnection>>();