Closed safari137 closed 1 year ago
I have an app that makes many calls to LDAP. I'd like to re-use the connections as much as possible.
I ran across this: #86
In my case, creating a connection adds ~150ms to each operation. Not the end of the world, but unnecessary. The above issue suggests creating a connection pool. Is there any guidance on this? Or has it already been done?
Just make a class to handle that, use factory pattern with queues if it is not thread safe, if it is, just reuse the object, like that:
public interface ILdapConnectionFactory
{
LdapConnection GetLdapConnection();
}
public class LdapConnectionFactory : ILdapConnectionFactory
{
static LdapConnection _ldapConnection;
public LdapConnection GetLdapConnection()
{
if(_ldapConnection is null)
_ldapConnection = CreateLdapConnection();
return _ldapConnection;
}
static LdapConnection CreateLdapConnection()
{
// Pass your setup here
}
}
I have an app that makes many calls to LDAP. I'd like to re-use the connections as much as possible.
I ran across this: https://github.com/dsbenghe/Novell.Directory.Ldap.NETStandard/issues/86
In my case, creating a connection adds ~150ms to each operation. Not the end of the world, but unnecessary. The above issue suggests creating a connection pool. Is there any guidance on this? Or has it already been done?