public void ReUsePoolConnection_test() { var host = "127.0.0.1"; var port = 6379; var connections = new List <RedisConnection>() { RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) }; foreach (var conn in connections) { conn.OnConnectionReleased(); } Assert.True(RedisConnectionPool.GetPoolSizeForHost(host, port).Equals(6)); var newConn = RedisConnectionPool.GetConnection(host, port); Assert.True(connections.Any(c => c.Id.Equals(newConn.Id))); }
public void SteadyStatePoolSize_test() { var host = "127.0.0.1"; var port = 6379; var connections = new List <RedisConnection>() { RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) }; Assert.True(RedisConnectionPool.GetPoolSizeForHost(host, port).Equals(6)); var incrementalConnections = new List <RedisConnection>() { RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) , RedisConnectionPool.GetConnection(host, port) }; Assert.True(RedisConnectionPool.GetPoolSizeForHost(host, port).Equals(9)); foreach (var conn in incrementalConnections) { conn.OnConnectionReleased(); } Assert.True(RedisConnectionPool.GetPoolSizeForHost(host, port).Equals(6)); foreach (var conn in connections) { conn.OnConnectionReleased(); } Assert.True(RedisConnectionPool.GetPoolSizeForHost(host, port).Equals(6)); }