接続プール
本製品 は標準ADO.NETコネクションプーリングを実装しています 。プーリングの有効化にはUseConnectionPooling を設定します。次のセクションでは、それらの設定および使用方法について説明します。
プールされた接続の操作
プールされていない接続との通信と同じように、標準ADO.NET オブジェクトを使って接続を開いたり、閉じたりすることができます。この場合、取得されたSharePoint Connection オブジェクトは、コネクションプールにより所有される物理的接続のハンドルです。接続が閉じられると、接続が廃棄されずにハンドルがプールに戻され、次の接続リクエストに使われます。
プールに戻されるには、明示的に接続を閉じなければなりません。
プールされた接続のインストール
コネクションプールは、Pool プロパティと永続化された一時的な値を除いて、一意の接続文字列に基づいています。次の例では、3つの接続を2つの異なるコネクションプールで作成します。2つの接続は、同じ接続文字列を共有していて、同じコネクションプールを共有しています。
C#
using (SharePointConnection connection = new SharePointConnection("User=MyUserAccount;Password=MyPassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;")) {connection.Open();}
using (SharePointConnection connection = new SharePointConnection("PoolIdleTimeout=-1;User=MyUserAccount;Password=MyPassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;")) {connection.Open();}
using (SharePointConnection connection = new SharePointConnection("Timeout=15;User=MyUserAccount;Password=MyPassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;")) {connection.Open();} //spawns a new pool
VB.NET
Using (SharePointConnection connection = new SharePointConnection("User=MyUserAccount;Password=MyPassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;"))
connection.Open()
End Using
Using (SharePointConnection connection = new SharePointConnection("PoolIdleTimeout=-1;User=MyUserAccount;Password=MyPassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;")) //same connection pool
connection.Open()
End Using
Using (SharePointConnection connection = new SharePointConnection("Timeout=15;User=MyUserAccount;Password=MyPassword;Auth Scheme=NTLM;URL=http://sharepointserver/mysite;")) //spawns a new connection pool
connection.Open()
End Using
コネクションプールを閉じる
アクティブ処理が終了するとコネクションプールは閉じられます。