public void Pool_Send_Get_TimeOut() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 2, MinClients = 1, SendTimeout = 5, ReceiveTimeout = 5 }); var par = Parallel.For(0, 1000, new ParallelOptions() { MaxDegreeOfParallelism = 100 }, (index, item) => { prc.Set("Parallel_PoolClient_Test" + index, "Parallel_PoolClient_Test"); var info2 = prc.Get("Parallel_PoolClient_Test" + index); Assert.AreEqual(info2.ToString(), "Parallel_PoolClient_Test"); }); Thread.Sleep(5000); prc.Dispose(); }
public void Parallel_PoolClient_Test() { PoolRedisClient prc = new PoolRedisClient(new PoolConfiguration() { Host = ip, Port = port, MaxClients = 100 }); Parallel.For(0, 1000, new ParallelOptions() { MaxDegreeOfParallelism = 100 }, (index, item) => { using (var client = prc.GetClient()) { Thread.Sleep(100); client.Set("Parallel_PoolClient_Test" + index, "Parallel_PoolClient_Test"); var info2 = client.Get("Parallel_PoolClient_Test" + index); Assert.AreEqual(info2.ToString(), "Parallel_PoolClient_Test"); } }); prc.Dispose(); }
public void Thread_PoolClient_Test() { PoolRedisClient prc = new PoolRedisClient(new PoolConfiguration() { Host = ip, Port = port }); Parallel.For(0, 1000, new ParallelOptions() { MaxDegreeOfParallelism = 100 }, (index, item) => { var t = new Thread(() => { Thread.Sleep(1000); object info2; using (var client = prc.GetClient()) { client.Set("Parallel_PoolClient_Test" + index, "Parallel_PoolClient_Test"); Thread.Sleep(15000); info2 = client.Get("Parallel_PoolClient_Test" + index); } Assert.AreEqual(info2.ToString(), "Parallel_PoolClient_Test"); }); t.Start(); }); Thread.Sleep(20000); prc.Dispose(); }
public void Pool_Single() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 100 }); prc.Set("GetClient_Test", "GetClient_Test"); var info2 = prc.Get("GetClient_Test"); Assert.AreEqual(info2.ToString(), "GetClient_Test"); prc.Dispose(); }
public void Pool_Single() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 100 }); prc.Set("GetClient_Test", "GetClient_Test"); var info2 = prc.Get("GetClient_Test"); Assert.AreEqual(info2.ToString(), "GetClient_Test"); prc.Dispose(); }
public void Pool_Multi() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 100 }); var info = prc.Multi(client => { client.Set("GetClient_Test", "GetClient_Test"); return client.Get("GetClient_Test"); }); Assert.AreEqual(info.ToString(), "GetClient_Test"); prc.Dispose(); }
public void Pool_Single_TimeOut() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 10 }); prc.Set("PoolClient_TimeOut_Test", "PoolClient_TimeOut_Test"); Thread.Sleep(15000); object info2 = prc.Get("PoolClient_TimeOut_Test"); Assert.AreEqual(info2.ToString(), "PoolClient_TimeOut_Test"); prc.Dispose(); }
public void Pool_Multi() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 100 }); var info = prc.Multi(client => { client.Set("GetClient_Test", "GetClient_Test"); return(client.Get("GetClient_Test")); }); Assert.AreEqual(info.ToString(), "GetClient_Test"); prc.Dispose(); }
public void Pool_Single_For() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 10 }); for (int i = 0; i < 100; i++) { prc.Set("GetMaxClient_Test" + i, "GetMaxClient_Test"); var info2 = prc.Get("GetMaxClient_Test" + i); Assert.AreEqual(info2.ToString(), "GetMaxClient_Test"); } prc.Dispose(); }
public void GetClient_Test() { PoolRedisClient prc = new PoolRedisClient(new PoolConfiguration() { Host = ip, Port = port, MaxClients = 100 }); using (var client = prc.GetClient()) { client.Set("GetClient_Test", "GetClient_Test"); var info2 = client.Get("GetClient_Test"); Assert.AreEqual(info2.ToString(), "GetClient_Test"); } prc.Dispose(); }
public void PoolClient_TimeOut_Test() { PoolRedisClient prc = new PoolRedisClient(new PoolConfiguration() { Host = ip, Port = port, MaxClients = 100 }); object info2; using (var client = prc.GetClient()) { var result = client.Set("PoolClient_TimeOut_Test", "PoolClient_TimeOut_Test"); Thread.Sleep(15000); info2 = client.Get("PoolClient_TimeOut_Test"); } Assert.AreEqual(info2.ToString(), "PoolClient_TimeOut_Test"); prc.Dispose(); }
public void Pool_Send_Get_TimeOut() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 2, MinClients = 1, SendTimeout = 5, ReceiveTimeout = 5 }); var par = Parallel.For(0, 1000, new ParallelOptions() {MaxDegreeOfParallelism = 100}, (index, item) => { prc.Set("Parallel_PoolClient_Test" + index, "Parallel_PoolClient_Test"); var info2 = prc.Get("Parallel_PoolClient_Test" + index); Assert.AreEqual(info2.ToString(), "Parallel_PoolClient_Test"); }); Thread.Sleep(5000); prc.Dispose(); }
public void Pool_Single_Parallel() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 20, MinClients = 10, }); Parallel.For(0, 1000, new ParallelOptions() { MaxDegreeOfParallelism = 100 }, (index, item) => { prc.Set("Parallel_PoolClient_Test" + index, "Parallel_PoolClient_Test"); var info2 = prc.Get("Parallel_PoolClient_Test" + index); Assert.AreEqual(info2.ToString(), "Parallel_PoolClient_Test"); }); Thread.Sleep(5000); prc.Dispose(); }
protected override void CloseTarget() { base.CloseTarget(); _pool.Dispose(); }
public void Pool_Single_For() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 10 }); for (int i = 0; i < 100; i++) { prc.Set("GetMaxClient_Test" + i, "GetMaxClient_Test"); var info2 = prc.Get("GetMaxClient_Test" + i); Assert.AreEqual(info2.ToString(), "GetMaxClient_Test"); } prc.Dispose(); }
public void Pool_Single_TimeOut() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 10 }); prc.Set("PoolClient_TimeOut_Test", "PoolClient_TimeOut_Test"); Thread.Sleep(15000); object info2 = prc.Get("PoolClient_TimeOut_Test"); Assert.AreEqual(info2.ToString(), "PoolClient_TimeOut_Test"); prc.Dispose(); }
public void Pool_Single_Parallel() { PoolRedisClient prc = new PoolRedisClient(new PoolConfig() { Host = ip, Port = port, MaxClients = 20, MinClients = 10, }); Parallel.For(0, 1000, new ParallelOptions() {MaxDegreeOfParallelism = 100}, (index, item) => { prc.Set("Parallel_PoolClient_Test" + index, "Parallel_PoolClient_Test"); var info2 = prc.Get("Parallel_PoolClient_Test" + index); Assert.AreEqual(info2.ToString(), "Parallel_PoolClient_Test"); }); Thread.Sleep(5000); prc.Dispose(); }